java - Why doesn't onActivityResult() work? -
what aiming here change picture of "ibchamp" default 1 "ahri". note names inside ***s names of activity.
***createbuilds.java*** ibchamp.setonclicklistener(new onclicklistener() { public void onclick(view arg0) { intent champs = new intent(createbuilds.this, champions.class); //creates intent champs startactivityforresult() startactivityforresult(champs, 0); //opens champions.class layout } }); protected void onactivityresult(int requestcode, int resultcode, int data){ //starts when this.finish() champions ran imagebutton ibchamp = (imagebutton) findviewbyid(r.id.ibchamp); //creates imagebutton ibchamp ibchamp.setimageresource(r.drawable.ahri); //sets picture of ibchamp "ahri" }; ***champions.java**** private myapplicationtest mytestinst = new myapplicationtest(); public void changepicture(final int champion){ mytestinst.setint(champion); //runs "setint" myapplicationtest class this.finish(); //closes current layout run onactivityresult } in code, onactivityresult() not seem run, since after "champions.java" finished, "ibchamp"'s picture did not change. if there extremely obvious, please state it, , questions welcomed.
finish() terminate activity. imho, not make sense call finish() , layout changes (i ssume on view in activity finished).
Comments
Post a Comment