Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change textview according to the change in the activity
    text
    copied!<p>i am new at android development .I am making a quiz with 10 questions (10 activities). there is another activity(name "Lost") which opens on wrong answer and contains a TextView(telling the score up-till now) according to the question number (activity number). I AM NOT ABLE TO SET THE TEXTVIEW ACCORDING TO THE ACTIVITY NUMBER. for example , if a person loses at 5th ques the activity(Lost) open and set the textview to 50 , and when person gives wrong answer at 9th ques the activity(Lost) opens and set the textview to 90. i dont know how to do this .. help me </p> <p>this is my code-</p> <p>that is 1st ques (similar code is for other questions) -</p> <pre><code> RadioGroup rg1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_level1); // Show the Up button in the action bar. setupActionBar(); rg1=(RadioGroup)findViewById(R.id.rg1); rg1.setOnCheckedChangeListener(this); } /** * Set up the {@link android.app.ActionBar}, if the API is available. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.level1, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back // NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } @Override public void onCheckedChanged(RadioGroup arg0, int arg1) { // TODO Auto-generated method stub switch(arg1){ case R.id.r11: RadioButton ans=(RadioButton)findViewById(R.id.r11); ans.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ Intent myintent=new Intent(view.getContext(), Level2.class); startActivityForResult(myintent,0); } }); break; case R.id.r12: RadioButton ans1=(RadioButton)findViewById(R.id.r12); ans1.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ Intent myintent=new Intent(view.getContext(), Lost.class); startActivityForResult(myintent,0); } }); case R.id.r13:RadioButton ans2=(RadioButton)findViewById(R.id.r13); ans2.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ Intent myintent=new Intent(view.getContext(), Lost.class); startActivityForResult(myintent,0); } }); break; case R.id.r14:RadioButton ans3=(RadioButton)findViewById(R.id.r14); ans3.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ Intent myintent=new Intent(view.getContext(), Lost.class); startActivityForResult(myintent,0); } }); break; } } </code></pre> <p>this is "Lost" activity code</p> <pre><code> @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lost); // Show the Up button in the action bar. setupActionBar(); Button home=(Button)findViewById(R.id.Home); home.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ Intent myintent=new Intent(view.getContext(), MainActivityQuiz.class); startActivityForResult(myintent,0); } }); } /** * Set up the {@link android.app.ActionBar}, if the API is available. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.lost, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back // NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); } </code></pre> <p>plz tell me how to do that....</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload