0
我需要使用RecyclerView
將圖像設置爲壁紙。在我的適配器我使用這個代碼:使用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)
我怎麼可以設置的項目從適配器中選擇作爲壁紙?
這將是有益的,如果你能爲的GridItem類粘貼代碼 –