我需要使用RecyclerView
. 在我的适配器中,我正在使用以下代码:
@Override
public void onBindViewHolder(ViewHolder viewHolder, final int i) {
final GridItem nature = mItems.get(i);
viewHolder.tvspecies.setText(nature.getName());
viewHolder.imgThumbnail.setImageResource(nature.getThumbnail());
viewHolder.imgThumbnail.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.i("CLick",nature.toString());
try {
wallpaper.setResource(mItems.get(i));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
所以onClick我应该将图像设置为墙纸,但在“setResource”字下我有这个错误:
The method setResource(int) in the type WallpaperManager is not applicable for the arguments (GridItem)
如何将从适配器中选择的项目设置为墙纸?