[英]i want to open an image in another activity when clicked on the item in the listview
[英]change image when I clicked on listview item
我正在嘗試制作媒體播放器應用。 在listView
存在音樂。 當我單擊該行右側的一項時,似乎正在播放圖像。 但是,當我單擊一個項目時,在listView
不可見一側,還會出現另一個圖像。 我進行了很多搜索,但我找不到適合我的解決方案。 請幫我。 謝謝!
public void createAnaTablo() {
lv = (ListView) findViewById(R.id.listview);
final MyCustomAdapter adapter = new MyCustomAdapter(
MediaPlayerliClass.this, parcalar);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
p = position;
sound_id = MediaPlayerliClass.this.getResources()
.getIdentifier(parcalar.get(position), "raw",
MediaPlayerliClass.this.getPackageName());
if (mp != null) {
mp.stop();
mp.release();
mp = null;
}
if (prevView != null) {
prevView.findViewById(R.id.simge).setBackgroundResource(0);
}
prevView = view;
mp = MediaPlayer.create(MediaPlayerliClass.this, sound_id);
mp.start();
animation = new AnimationDrawable();
animation.addFrame(getResources().getDrawable(R.drawable.equ1),
75);
animation.addFrame(getResources().getDrawable(R.drawable.equ2),
125);
animation.addFrame(getResources().getDrawable(R.drawable.equ3),
175);
animation.setOneShot(false);
view.findViewById(R.id.simge)
.setBackgroundDrawable(animation);
// start the animation!
animation.start();
stop.setBackgroundResource(R.drawable.pause);
seekBar.setMax(mp.getDuration());
if (updateSeekBar.getState() == Thread.State.NEW) {
updateSeekBar.start();
}
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
mp.seekTo(seekBar.getProgress());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
}
});
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.