imageview - How to pass a jpg id between activities Android -


i have gridview imageviews in 1 activity , want load 1 of them in other activity on new imageview when select it, have no results

activity 1:

public class level extends activity{ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.level);      gridview gridview = (gridview) findviewbyid(r.id.gridviewlevel);     imageadapter ia = new imageadapter(this);     gridview.setadapter(ia);      gridview.setonitemclicklistener(new onitemclicklistener() {         public void onitemclick(adapterview<?> parent, view v, int position, long id) {             toast.maketext(level.this, "" + position, toast.length_short).show();             initimagecheck( v.getid());         }     }); }  public void initimagecheck(int id){     intent intentic = new intent(this, imagecheck.class);     intentic.putextra("id", id);     startactivity(intentic); } 

}

activity 2:

public class imagecheck extends activity{ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.image_check);      bundle extras = getintent().getextras();     int id = extras.getint("id");      imageview imgview = (imageview) findviewbyid(r.id.imageviewcheck);      imgview.setimageresource(id); } 

}

whats problem??? thanks.

v.getid() id of view, not of image resource.

have imageadapter hold id of resource used per item, , provide method getresourceidforitem(int position).


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -