Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 一个屏幕上的对象太多。建议_Android_Xml_Layout - Fatal编程技术网

Android 一个屏幕上的对象太多。建议

Android 一个屏幕上的对象太多。建议,android,xml,layout,Android,Xml,Layout,我有一个活动屏幕,它只为1条记录提取mysql数据(永远不会超过1条)。我需要在屏幕上显示所有这些信息。我按我想要的方式放置了feild,但是我收到一个通知,屏幕上的对象太多了。我已经阅读了一些关于使用listview的不同答案,但我认为这不适用于这里,因为我只显示了一条记录。我现在把所有的数据都放在表格格式中。我可以得到一些关于我可以对布局进行哪些更改以使其更加精简的信息吗 activity_loads.xml <?xml version="1.0" encoding="utf-8"?

我有一个活动屏幕,它只为1条记录提取mysql数据(永远不会超过1条)。我需要在屏幕上显示所有这些信息。我按我想要的方式放置了feild,但是我收到一个通知,屏幕上的对象太多了。我已经阅读了一些关于使用listview的不同答案,但我认为这不适用于这里,因为我只显示了一条记录。我现在把所有的数据都放在表格格式中。我可以得到一些关于我可以对布局进行哪些更改以使其更加精简的信息吗

activity_loads.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<LinearLayout
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".LoadsActivity"
    android:scrollbarStyle="insideOverlay">

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/spinner" />

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:layout_marginEnd="20dp"
            android:layout_marginStart="10dp"
            android:text="@string/LoadNumber"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:layout_marginEnd="20dp"
            android:text="@string/AddlStops"
            />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:layout_marginStart="10dp"
            android:id="@+id/textViewLoadNumber"
            android:textColor="#ff0000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:id="@+id/textViewAddlStops"
            android:layout_marginStart="100dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ShipperName"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipName"
            android:layout_marginStart="50dp"
            android:textColor="#0404b4" />

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ShipperAddr" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipAddr"
            android:textColor="#0404b4"
            android:layout_marginStart="35dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:text="@string/MapIt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ShipMap"
            android:elevation="4dp"
            android:maxHeight="40dp"
            android:minHeight="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipAddr2"
            android:layout_marginStart="50dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipCity"
            android:layout_marginStart="140dp"
            android:textColor="#0404b4" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipState"
            android:textColor="#0404b4"
            android:layout_marginStart="20dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ShipperPhone"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipPhone"
            android:layout_marginStart="47dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ShipperContact"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewShipContact"
            android:layout_marginStart="37dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/PUDateTime"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewPUDate"
            android:textColor="#ff0000"
            android:layout_marginStart="26dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewPUTime"
            android:layout_marginStart="20dp"
            android:textColor="#ff0000" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/CustomerPO"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewCustomerPO"
            android:layout_marginStart="60dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/Weight"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewWeight"
            android:layout_marginStart="10dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/Pieces"
            android:layout_marginStart="10dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewPieces"
            android:layout_marginStart="10dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/BLNumber"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewBLNumber"
            android:layout_marginStart="59dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/TrlrNumber"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewTrlrNumber"
            android:textStyle="bold"
            android:textColor="#229954"
            android:layout_marginStart="48dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ConsigneeName"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsName"
            android:layout_marginStart="34dp"
            android:textColor="#0404b4" />

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ConsigneeAddr"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsAddr"
            android:layout_marginStart="20dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:text="@string/MapIt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ConsMap"
            android:elevation="4dp"
            android:maxHeight="40dp"
            android:minHeight="30dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsAddr2"
            android:layout_marginStart="50dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsCity"
            android:layout_marginStart="142dp"
            android:textColor="#0404b4" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsState"
            android:layout_marginStart="20dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ConsigneePhone"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsPhone"
            android:layout_marginStart="35dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/ConsigneeContact"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewConsContact"
            android:layout_marginStart="28dp"
            android:textColor="#0404b4" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/DelDateTime"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewDelDate"
            android:textColor="#ff0000"
            android:layout_marginStart="23dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewDelTime"
            android:textColor="#ff0000"
            android:layout_marginStart="20dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/DrvLoad"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewDrvLoad"
            android:layout_marginStart="20dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/DrvUnload"
            android:layout_marginStart="20dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewDrvUnload"
            android:layout_marginStart="20dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/LoadedMiles"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewLoaded"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/EmptyMiles"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewEmpty"
            android:layout_marginStart="25dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/TempLow"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewTempLow"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/TempHigh"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewTempHigh"
            android:layout_marginStart="25dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/Preloaded"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewPreload"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/DropHook"
            android:layout_marginStart="25dp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewDropHook"
            android:layout_marginStart="25dp" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:text="@string/Comments"
            />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textViewComments"
            />
    </TableRow>
</LinearLayout>
</ScrollView>
activity\u loads.xml

坦率地说,不管是什么问题,这种设计都是违反直觉的,很难理解。不要将其框架化为表格,而是使用listview将每一行添加到列表中,或者如果字段是静态的,则创建静态滚动视图,并用数据库中查询的数据填充文本。

您必须重新考虑您的设计。。。也许找个设计师吧!?:/我将尝试重写页面,但是,由于这些信息是从大型机中提取的,因此我受到了限制。我正在学习ListView和自定义适配器的灵活性。我不确定静态scollview,但我会检查它。