为什么listview项目最初被禁用?

时间:2013-10-23 17:02:32

标签: android listview android-listview

我有以下作为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>

但每次我得到这个:

enter image description here

正如您所看到的,两个按钮和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>

1 个答案:

答案 0 :(得分:0)

它只能正常工作。屏幕被禁用,因为当模拟器打开时,您应该使用它。如果你将它保持空闲状态,它将隐藏这些控件。当您单击模拟器屏幕内的任何位置时。它将采取控制。