Since getBooleanExtra
method has two values - true
and false
, how to write code using getBooleanExtra to display two different string values?
For example pressing RadioButton1
should display string from getBooleanExtra 1
and pressing RadioButton2
should display string 2
.
I wrote something like this but it isn't doing the job.
textViewDisplayResult.setText(getIntent().getBooleanExtra("KEY_ANSWER", false)?getString(R.string.1):getString(R.2));
POST UPDATE
so how to pass values to other activity
using Bundle
in below case?
final Intent intent = new Intent(MainActivity.this, AnswerActivity.class);
buttonCheckAnswer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!allAnswersChecked())
intent.putExtra("KEY_ALL_CHECKED", R.string.text_not_checked);
else if (checkAnswers())
intent.putExtra("KEY_ANSWER", R.string.Good_answer);
else
intent.putExtra("KEY_ANSWER", R.string.Wrong_answer);
startActivity(intent);
}
});