如果TableRows的数量超过一定数量,为什么TableLay中没有显示带TextViews的TableRows?

时间:2014-07-13 20:14:36

标签: java android android-layout android-tablelayout

这是我第一次尝试编写一个“简单”的Android应用程序。可悲的是,我认识到我的应用程序显示csv文件中的内容在我的galaxy sIII mini中与AVD相比看起来不同。奇怪的是,在AVD中 - 例如400 - csv文件中的条目可以正确显示。与我的智能手机相比,TableLayout由包含TextViews的TableRows组成,不显示任何值(不会发生错误)。如果我更改csv文件中的行数(例如从400到80),则智能手机屏幕上将显示TextView。奇怪的是,似乎没有显示的内容存在但不可见。如果我点击智能手机的屏幕,则会调用click事件,我可以在日志输出中看到值正在打印到控制台。

正在运行时添加TableRows和TextView。 TextViews的数量取决于列数,TableRows的数量取决于csv文件中的条目。 “firstAddressRow”填充了列标题。

这是我正在使用的活动对象的布局定义:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/background_panel">
    <Button android:layout_width="fill_parent" android:layout_height="40dp" android:onClick="updateCanvas" android:text="Update"/>
    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            android:scrollbars="vertical">
        <LinearLayout android:id="@+id/linearLayout"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:orientation="vertical">
            <HorizontalScrollView android:id="@+id/horizontalScrollView"
                                  android:layout_width="wrap_content" android:layout_height="wrap_content">
                <TableLayout
                        android:id="@+id/addressTable"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:padding="10dp"
                        android:orientation="horizontal"
                        android:alpha="0.9">
                    <TableRow
                            android:id="@+id/firstAddressRow">
                    </TableRow>
                </TableLayout>
            </HorizontalScrollView>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

有谁知道我的错误在哪里?我想也许我必须再次刷新或更新布局和视图,但没有“无效”或更新功能成功。

我在顶部插入的按钮只是一个实验。 updateCanvas方法只删除一些TableRows,奇怪的是如果删除了足够的TableRows,我会再次看到TextViews。而且我知道我已经在介绍中提到了它,但是使用AVD它工作正常。如果有人可以帮助我,我真的很感激...这太令人沮丧......

如果您需要更多信息或更多代码,请告知我们。

0 个答案:

没有答案