Value Of Passed Integer Always Resets Back To Default Value
Bal keeps resetting to 0. Continue = (Button)findViewById(R.id.btnContinue); Continue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View vi
Solution 1:
You're putting 0 in the Intent for "intBalance", instead of putting the value Bal.
Continue = (Button)findViewById(R.id.btnContinue);
Continue.setOnClickListener(new View.OnClickListener() {
@Override
publicvoid onClick(View view) {
Intent startIntent = new Intent(SecondActivity.this, Mainmenu.class);
int Bal = Integer.parseInt(Balance.getText().toString());
int MonthlyTarget = Integer.parseInt(Target.getText().toString());
// Change 0 to Bal
startIntent.putExtra("intBalance", Bal);
startIntent.putExtra("intTarget", MonthlyTarget);
startActivity(startIntent);
}
});
P.S - Try to follow naming conventions, although it might seem inconsequential, it's easy to miss simple things when variable names look like class names.
Also, don't unnecessarily create variables like startIntent, RecordExpense & RecordExpense. getIntent() already gives you access to the intent, you don't need to get and store a reference to it in a variable everytime.
Post a Comment for "Value Of Passed Integer Always Resets Back To Default Value"