2012-03-09 120 views
1

我一直在尋找這個很長一段時間,但似乎無法找到它。Android中的基本可點擊項目

有Android中任何預定義的小部件來實現基本的可點擊的項目(有兩行文字之一),其背景點擊時,就像在這裏看到的那些,例如轉向主題的顏色:

enter image description here

我的意思是,不使用PreferenceActivity類,它會自動實現這一點。這是存在還是必須實現我自己的自定義視圖?

謝謝!

編輯:

我添加了一個TwoLineListItem這樣,它不以點擊反應(背景不會改變)

<TwoLineListItem 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    > 

    <TextView android:id="@android:id/text1" 
     android:layout_marginTop="1dip" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="15sp" 
     android:textStyle="bold" 
     android:text="Meh" /> 

    <TextView android:id="@android:id/text2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@android:id/text1" 
     android:layout_alignLeft="@android:id/text1" 
     android:paddingBottom="4dip" 
     android:includeFontPadding="false" 
     android:textSize="15sp" 
     android:textStyle="normal" 
     android:text="Moo" /> 

</TwoLineListItem> 

是否只是內部列表視圖工作?因爲這樣我必須在代碼中定義我的按鈕而不是在XML中,對吧?

謝謝!

回答

0

ListView中的所有項目都支持此轉換。

最良好的祝願, 添

+0

啊,所以你的意思是使用ListItems作爲按鈕。謝謝! – 2012-03-09 14:57:27