2013-10-23 39 views
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> 

但每次我得到這個:

enter image description here

正如你可以看到,這兩個按鈕以及因爲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> 
+1

你可以編輯你的問題,並添加你的ListView XML佈局和你的Java類適配器? –

+0

你是什麼意思禁用?你想說你的listView項目的onItemclick不會觸發嗎? –

+0

我編輯了我的問題。而通過「殘疾人」,我的意思是你所看到的。按鈕的「外觀」告訴我的意思。 –

回答

0

它只能正常工作。該屏幕被禁用,因爲當模擬器打開時,您應該使用它。如果你保持它閒置,它會隱藏這些控制。當你點擊模擬器屏幕內的任何地方時。它會採取控制。

+0

情況並非如此。只要看看第一個視圖(TextView):它已啓用! –

+0

你可以在你的xml佈局中添加列表視圖嗎? becoz我檢查了你的代碼。它工作正常。在你的問題編輯 –

+0

我做到了。怎麼辦? –

相關問題