I am having quite a simple problem.
I want to take an numerical input in an activity then display that on another activity.
input.java
Button ok = (Button) findViewById(R.id.inputok);
ok.setOnClickListener (new OnClickListener ()
{
public void onClick(View vie)
{EditText et = (EditText) findViewById(R.id.ei);
a = Integer.valueOf(et.getText().toString());
Intent intent= new Intent (input.this, answer.class);
intent.putExtra("i", a );
startActivity(intent);
}
} );
Now before displaying it on another i want to perform some action on the integer, say +1 to it.
answer.java
Bundle extras = getIntent().getExtras();
int a = extras.getInt("i");
++a;
TextView TV= (TextView) findViewById(R.id.TV);
TV.setText(a);
When i try to run this, the app closes, is there something wrong with the code??
May i hope the problem is to set the integer value in an
setText();Try this,
or you can use,