Set ImageView to a drawable (Android) -
forgive me being new , teminology may incorrect:
i have array of images in class1, when image selected id passed class2 (code below) display image , give option set wallpaper. problem is, using code below need drawable assign wallpaper, not imageview. can give me guidance in referencing actual drawable have "mywallpapermanager.setresource(need drawable here);"
thanks in advance. hope makes sense, said noob!
public class fullwallview extends activity { private button wallbutton; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.wallpaper_full); // intent data intent = getintent(); // selected image id int position = i.getextras().getint("id"); imageadapter imageadapter = new imageadapter(this); imageview imageview = (imageview) findviewbyid(r.id.full_wall_view); imageview.setimageresource(imageadapter.mthumbids[position]); //making button clickable , setting wallpaper wallbutton = (button) findviewbyid(r.id.apply); wallbutton.setonclicklistener(new button.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub wallpapermanager mywallpapermanager = wallpapermanager.getinstance(getapplicationcontext()); try { mywallpapermanager.setresource(need drawable here); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } }});
first define drawable, set in imageview.
img=(imageview)findviewbyid(r.id.imageview1); drawable mydrawable = getresources().getdrawable(r.drawable.imageview1); img.setimagedrawable(mydrawable);
Comments
Post a Comment