java - Set wallpaper using RecyclerView -
i need set image wallpaper using recyclerview
. in adapter i'm using code:
@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(); } } }); }
so onclick should set image wallpaper under "setresource" word have error:
the method setresource(int) in type wallpapermanager not applicable arguments (griditem)
how can set item selected adapter wallpaper?
the reason program not working, method setresource(int)
takes in int
type parameter , not griditem
type.
reading more documentation
change current system wallpaper bitmap in given resource. resource opened raw data stream , copied wallpaper; must valid png or jpeg image.
also make sure app have permission set wallpaper in manifest
this method requires caller hold permission set_wallpaper.
Comments
Post a Comment