So I have this class where I push a button, and at the and I get the int maxpluseen
which I want to pass over to 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 the 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 it gives back 0 (so my int isn't passed from classA
to classB
. What am I doing wrong here?