ListviewActivityを使用するサウンドボードアプリケーションを開発しています。ただし、Androidのリストビューにはリストビューをリサイクルするプロパティがあるため、選択したテキストビューに加えた変更は、リストビューをスクロールしているときにすべてのページに反映されます。私はこれが起こらないようにしたい。では、どうすれば適切に処理できますか。誰かがコードスニペットを手伝ってくれるなら、それは本当に役に立ちます。あなたの努力に感謝します。ありがとうございました!
編集:これがよりよく説明されることを願っています
私のクラスはListActivityを拡張し、リストビューは次のとおりです
[Image] [Text]
[Image] [Text]
[Image] [Text]
これで、ユーザーがテキストビューをクリックしたときに、そのテキストビューの画像を変更する必要があります。次のコードで実装します。
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);
}
};
}