我有一個列表視圖包含一個按鈕和一個文本視圖正在點擊正常;但我有一個按鈕點擊的方法,當點擊按鈕它應該改變背景圖像,所以通過點擊一個按鈕所有的按鈕實例正在改變背景圖像,所以我點擊列表視圖中的fiew按鈕和向下滾動,我看到幾個按鈕的背景圖像改變的背景圖像比改變背景更改的按鈕的位置,同時再次滾動列表視圖; 我該如何解決這個問題?我有一個按鈕在列表視圖中,當點擊所有的實例被點擊
我的ListView的內容的代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/bt_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:background="@android:drawable/btn_star_big_off"
android:onClick="myClickHandler"/>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/fsinlistview"
/>
</LinearLayout>
我按一下按鈕的代碼是:
public void myClickHandler(View v)
{
Button button = (Button)v.findViewById(R.id.bt_rating);
button.setBackgroundResource(android.R.drawable.btn_star_big_on);
}
「myClickHandler」方法的代碼是什麼樣的? –