ListView の代わりに自分のビューを使用します。タッチ時に ListView で強調表示するように、タッチ時にこのビューを強調表示するにはどうすればよいですか?
1 に答える
2
ビューの背景としてセレクターを使用します。例: selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed_yellow"
android:state_pressed="true" />
<item android:drawable="@drawable/button_focused_orange"
android:state_focused="true" />
<item android:drawable="@drawable/button_normal_green" />
someOther.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<yourView
android:id="@+id/viewWithSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector.xml" />
于 2013-01-21T15:00:59.430 に答える