我有以下爲每個項目在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>
但每次我得到這個:
正如你可以看到,這兩個按鈕以及因爲TextViews被禁用(看看它們的外觀)。請注意,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>
你可以編輯你的問題,並添加你的ListView XML佈局和你的Java類適配器? –
你是什麼意思禁用?你想說你的listView項目的onItemclick不會觸發嗎? –
我編輯了我的問題。而通過「殘疾人」,我的意思是你所看到的。按鈕的「外觀」告訴我的意思。 –