2
我正在開發一個使用Listview Activity的音板應用程序。但是由於Android的Listview具有回收其列表視圖的屬性,我滾動列表視圖時,對選定文本視圖所做的更改反映在所有頁面中。我不希望發生這種情況。那麼我該如何正確處理它。如果有人可以用代碼片段幫助我,這將是非常有用的,我感謝你的努力。謝謝!Android:Handle ListView Recycle
編輯:希望這將更好地解釋
我的類擴展ListActivity和列表視圖如下
[Image] [Text]
[Image] [Text]
[Image] [Text]
現在,當用戶點擊任何TextView的,我需要改變的TextView的圖像。我通過下面的代碼來實現它。
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
TextView tv = (TextView) view;
//Here I change the image with tv as reference
final Resources res = getBaseContext().getResources();
final Drawable myImage = res.getDrawable(R.drawable.pause);
// myImage.
final Drawable myImage1 = res.getDrawable(R.drawable.play);
tv.setCompoundDrawablesWithIntrinsicBounds(myImage, null, null, null);
MediaPlayer.OnCompletionListener listener = new MediaPlayer.OnCompletionListener(){
public void onCompletion(MediaPlayer mp) {
tv.setCompoundDrawablesWithIntrinsicBounds(myImage1, null, null, null);
}
};
}
現在我編輯了我的問題。請看一下。現在你可以用代碼示例回答我了。謝謝 – Vivek 2010-12-09 07:58:57