android - In Eclipse Images are not clickable? -
ive made pretty simple wallpaper app , have used same code before. no errors reason images not clickable, missing help... here code far
import java.io.ioexception; import java.io.inputstream; import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.imageview; public class nflwallpapers extends activity implements view.onclicklistener{ imageview display; int tophone; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.main); tophone = r.drawable.azcard1; display = (imageview)findviewbyid(r.id.ivdisplay); imageview image1 = (imageview) findviewbyid(r.id.ivimage1); imageview image2 = (imageview) findviewbyid(r.id.ivimage2); imageview image3 = (imageview) findviewbyid(r.id.ivimage3); imageview image4 = (imageview) findviewbyid(r.id.ivimage4); imageview image5 = (imageview) findviewbyid(r.id.ivimage5); imageview image6 = (imageview) findviewbyid(r.id.ivimage6); button setwall = (button)findviewbyid(r.id.setwallpaper); image1.setonclicklistener(this); image2.setonclicklistener(this); image3.setonclicklistener(this); image4.setonclicklistener(this); image5.setonclicklistener(this); image6.setonclicklistener(this); setwall.setonclicklistener(this); } public void onclick(view v) { // todo auto-generated method stub switch (v.getid()){ case r.id.ivimage1: display.setimageresource(r.drawable.azcard1); tophone =r.drawable.azcard1; break; case r.id.ivimage2: display.setimageresource(r.drawable.azcard2); tophone =r.drawable.azcard2; break; case r.id.ivimage3: display.setimageresource(r.drawable.azcard3); tophone =r.drawable.azcard3; break; case r.id.ivimage4: display.setimageresource(r.drawable.azcard4); tophone =r.drawable.azcard4; break; case r.id.ivimage5: display.setimageresource(r.drawable.azcard5); tophone =r.drawable.azcard5; break; case r.id.ivimage6: display.setimageresource(r.drawable.azcard6); tophone =r.drawable.azcard6; break; case r.id.setwallpaper: inputstream yes = getresources().openrawresource(tophone); bitmap whatever = bitmapfactory.decodestream(yes); try{ getapplicationcontext().setwallpaper(whatever); }catch(ioexception e){ e.printstacktrace(); } break; } } };
well seem ok class. check out xml layout setting... horizontalscrollview , linearlayout..
Comments
Post a Comment