android - Pass integer between classes in Java -


this question has answer here:

so have class push button, , @ , int maxpluseen want pass on classb.

   private void populatebtn() {         foto1 = (button) this.findviewbyid(r.id.button2);         foto1.setonclicklistener(new view.onclicklistener() {             @suppresslint("simpledateformat")             @override             public void onclick(view v) {  int maxpluseen = maxindex + 1;                 log.d("log!", "uiteindelijk resultaat " + maxpluseen);                  intent myintent = new intent(classa.this, classb.class);                 classa.this.startactivity(myintent);                   }           });     } 

i tried doing following:

public static int access(int maxpluseen){   return maxpluseen;  } 

and in classb

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.info);       int maxpluseen = 0;     int test = classa.access(maxpluseen);     log.d("log!", "test int tussen klassen= " + test);  } 

but gives 0 (so int isn't passed classa classb. doing wrong here?

in class a:

intent myintent = new intent(classa.this, classb.class); myintent.putextra("number", maxpluseen)             classa.this.startactivity(myintent);  

in class b:

int getal; getal = getintent().getextras().getint("number"); 

......


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -