我有像这样的arraylist图像的回收视图
,它正在工作,现在无论我单击图像,它都会更改为itemClicked
方法上的newimages
,我该怎么做呢?注意:itemClicked
方法是从适配器回收器视图中实现的
public List<Information> getData(){
List<Information> data = new ArrayList<>();
int[] iconList = {R.drawable.th_ok,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small,R.drawable.thbg_small};
String[] titles = {"1","2","3","4","5","6","7","8","9","10"};
String[] subtitles = {"A","B","C","D","E","F","G","H","I","J" };
for(int i=0;i<titles.length && i<iconList.length;i++)
{
Information current = new Information();
current.iconth = iconList[i];
current.subtitle = subtitles[i];
data.add(current);
}
return data;
}
@Override
public void itemClicked(View view, int position) {
Resources res = getResources();
Drawable newimages = res.getDrawable(R.drawable.th_ok);
// startActivity(new Intent(treasure.this,MapsActivity.class));
}
发布于 2018-06-01 04:44:45
答案取自这个:How to change particular image in recycler view after clicking只需添加:
adapter.changeImage(position);
在itemClicked
方法上,在您遵循该链接答案之后。这应该是可行的
https://stackoverflow.com/questions/50630899
复制相似问题