我有一个列表视图,每行都有一个播放图像按钮......
播放和暂停功能
@Override
public void playPauseOnClick(int position) {
Product product = songList.get(position);
if (product.paused) {
product.setPlayPauseId(R.drawable.ic_pause);
product.paused=false;
}else {
product.setPlayPauseId(R.drawable.ic_play);
product.paused = true;
}
adapter.notifyDataSetChanged();
}
这很好用,我没有问题......
但现在我需要实现的是在将新位置设置为暂停之前将之前点击的位置设置回Play图标。
请帮助我!!,
答案 0 :(得分:1)
试试这个 -
@Override
public void playPauseOnClick(int position) {
Product product = songList.get(position);
for(int i=0;i< songList.size();i++)
{
songList.get(i).product.setPlayPauseId(R.drawable.ic_play);
songList.get(i).product.paused = true;
}
if (product.paused) {
product.setPlayPauseId(R.drawable.ic_pause);
product.paused = false;
} else {
product.setPlayPauseId(R.drawable.ic_play);
product.paused = true;
}
adapter.notifyDataSetChanged();
}
答案 1 :(得分:1)
我修改了Hitesh Gehlot的回答:
@Override
public void playPauseOnClick(int position) {
Product product = movieList.get(position);
if (product.paused) {
for(int i=0;i< movieList.size();i++)
{
movieList.get(i).setPlayPauseId(R.drawable.ic_play);
movieList.get(i).paused = true;
}
product.setPlayPauseId(R.drawable.ic_pause);
product.paused=false;
}else {
product.setPlayPauseId(R.drawable.ic_play);
product.paused = true;
}
adapter.notifyDataSetChanged();
}