我在列表中使用了几个按钮。我想点击它时所有按钮上都有一个按钮。它变成了奔跑。当然我的意思是出现和消失。 它是一个Recyclerview和音乐应用程序
我需要点击ply按钮或停止按钮所有imageview(ply)按钮更改以显示播放按钮(imageview)。
public void onBindViewHolder(final MyViewHolder holder, final int position) {
music music = musiclist.get(position);
holder.getAdapterPosition();
holder.imgback.setImageResource(music.pic);
holder.imgply.setImageResource(music.picply);
holder.imgstop.setImageResource(music.picstop);
holder.imgply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
holder.imgply.setVisibility(view.INVISIBLE);
holder.imgstop.setVisibility(View.VISIBLE);
if (position == 0) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
}
m1 = MediaPlayer.create(view.getContext(), R.raw.m1);
m1.start();
full = 1;
}
if (position == 1) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
}
m1 = MediaPlayer.create(view.getContext(), R.raw.m2);
m1.start();
full = 1;
}
if (position == 2) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
}
m1 = MediaPlayer.create(view.getContext(), R.raw.m3);
m1.start();
full = 1;
}
if (position == 3) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
}
m1 = MediaPlayer.create(view.getContext(), R.raw.m4);
m1.start();
full = 1;
}
if (position == 4) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
}
m1 = MediaPlayer.create(view.getContext(), R.raw.m3);
m1.start();
full = 1;
}
}
});
holder.imgstop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
holder.imgstop.setVisibility(View.INVISIBLE);
holder.imgply.setVisibility(View.VISIBLE);
if (position == 0) {
if (m1 != null) {
full = 0;
m1.stop();
m1.release();
m1 = null;
}
}
if (position == 1) {
if (m1 != null) {
m1.stop();
m1.release();
full = 0;
m1 = null;
}
}
if (position == 2) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
full = 0;
}
}
if (position == 3) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
full = 0;
}
}
if (position == 4) {
if (m1 != null) {
m1.stop();
m1.release();
m1 = null;
full = 0;
}
}
}
});
// notifyDataSetChanged();
}