0

我将以下内容作为 ListView 中每个项目的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent" >


<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />


<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

</LinearLayout>

但每次我得到这个:

在此处输入图像描述

如您所见,按钮和 TextView 都被禁用(看看它们的外观)。请注意,当我单击 ListView 中的每个单独项目时(我已定义 OnItemClickListener());唯一的问题(到目前为止)是按钮和文本视图的外观。这是 main_layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_weight="1"
    android:layout_height="0dp"
    android:hint="Text empty"
    android:text="TextView" />

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="9" >
</ListView>

</LinearLayout>
4

1 回答 1

0

它只是工作正常。屏幕被禁用,因为当模拟器打开时,您应该使用它。如果您让它处于空闲状态,它将隐藏这些控件。当您单击模拟器屏幕内的任意位置时。它会控制。

于 2013-10-23T17:33:53.743 回答