java - 将行动态添加到单独文件中的表布局

标签 java android layout tablerow

我有这样的东西:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/chooseBirthDateText"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                style="@style/mediumText"
                android:gravity="center_horizontal"
                android:text="@string/choose_birth_date" />

        </TableRow>
    </TableLayout>
</ScrollView>

我想添加更多行,但只能在一段时间后(假设 10 秒)。我想首先让这些行不可见,然后再让它们出现。但这样我的 ScrollView 就不能按我想要的方式工作(即使下面没有任何东西,我也可以向下滚动 - 因为行是不可见的)

所以我想在第二个文件中添加我想要添加的行,在中间加载它们并在它们必须出现时将它们添加到 tableRow1 之后。不幸的是我不知道如何做到这一点(我正在谈论连接 2 个文件,而不是在 java 中创建第二个文件):/

最佳答案

有两种隐藏 View 的模式:

  • INVISIBLE:此 View 不可见,但出于布局目的,它仍然占用空间。
  • GONE:此 View 不可见,并且不占用任何布局空间。

http://developer.android.com/reference/android/view/View.html#setVisibility(int)

我认为GONE会对您有所帮助。

关于java - 将行动态添加到单独文件中的表布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14831906/

相关文章:

java - lambda 表达式与静态方法

java - 具有多模块项目的 Liquibase

java - 从随机字符串中获取日期模式

java - 花车上意外的科学格式

rest - 如何使 flutter 中的无限滚动布局? (更新)

ruby-on-rails - 不呈现 Rails 3 中的默认应用程序布局

java - 在数据库中只存储没有时间的日期

android - openlayer map 的限制是什么

java - 如何修复 Timertask 只运行一次?

html - 我如何让一个元素忽略另一个边距,或者删除那个边距?