Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9240521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:12:14+00:00 2026-06-18T08:12:14+00:00

I’m facing a problem in Next button while displaying the next question. In my

  • 0

I’m facing a problem in Next button while displaying the next question.

In my first time set text I’m getting the correct question and matched four option answers. What I needed is.

I have a Next button for displaying the next question and answers. When I click on next button I can get the next four options for next question. But I can’t get next question after four times I click on next it shows next question, but answers are correct.

What I’m doing wrong? what I’m missing?

Any help would be appreciated.

    protected String doInBackground(String... Args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
    System.out.println("cool");
params.add(new BasicNameValuePair("tid", tid));
json = jsonParser.makeHttpRequest(url_get_quesurl, "GET", params);
System.out.println("ques value got");
Log.d("All Groups: ", json.toString());
    System.out.println("question");
try {
int success = json.getInt(TAG_SUCCESS);
System.out.println("Success");
if (success == 1) {
System.out.println("Success");
groups = json.getJSONArray(TAG_GROUP);
System.out.println("Result Success+++"+groups);
for (int i = 0; i < groups.length();i++) {
JSONObject c = groups.getJSONObject(i);
      String question = c.getString(TAG_QUES);
  System.out.println("Checking ::"+question);
ques1.add(question);
String answer = c.getString(TAG_ANSW);
System.out.println("Checking ::"+answer);
answ1.add(answer);
       }
    } else {
        showAlert();
    }
} catch (JSONException e) {
    System.out.println("Error "+e.toString());
}
return null;
     }  
     protected void onPostExecute(String file_url) {
     pDialog.dismiss();
     ques1=new ArrayList<String>(new ArrayList<String>(ques1));
        //  j=0;
        TextView txtque = (TextView) findViewById(R.id.que_txt); 
        txtque.setText(ques1.get(j));                      // here im getting the question
                                                 //   and answers in radiobutton text
        answ1=new ArrayList<String>(new ArrayList<String>(answ1));
        btn_practice1.setText(answ1.get(0));
        btn_practice2.setText(answ1.get(1));
        btn_practice3.setText(answ1.get(2));
        btn_practice4.setText(answ1.get(3));
        btn_practicerg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) { 
                RadioButton radioButton = (RadioButton) findViewById(checkedId);
               // Toast.makeText(Question.this, "" + radioButton.getText(), 2000).show(); 
                TextView txtRadio = (TextView) findViewById(R.id.rdtxt); 
                txtRadio.setText("" + radioButton.getText());
            }
});
    Button nextBtn = (Button) findViewById(R.id.nxt_btn);
    nextBtn.setOnClickListener(new Button.OnClickListener(){
      public void onClick(View v){  
      j++;
    TextView txtque = (TextView) findViewById(R.id.que_txt); 
    txtque.setText(ques1.get(j));              // here im not getting the next question
                                            //   but i can get the next four options in              
                                            //    radiobutton text
    k++;
    btn_practice1.setText(answ1.get((k*4)+0));
    btn_practice2.setText(answ1.get((k*4)+1));
    btn_practice3.setText(answ1.get((k*4)+2));
    btn_practice4.setText(answ1.get((k*4)+3));
     }
   });
    Button previousbtn = (Button) findViewById(R.id.prv_btn);
previousbtn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
j--;
TextView txtque = (TextView) findViewById(R.id.que_txt); 
txtque.setText(ques1.get(j));              // here also im not getting the perivous question
                                        //     but i cant get perivous four options in 
                                       //      radiobutton text
k--;
btn_practice1.setText(answ1.get((k*4)+0));
btn_practice2.setText(answ1.get((k*4)+1));
btn_practice3.setText(answ1.get((k*4)+2));
btn_practice4.setText(answ1.get((k*4)+3));
  }
});
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:12:14+00:00Added an answer on June 18, 2026 at 8:12 am

    I assume, you are trying to manage question and its options on next/previous buttons click.

    I achieved in my one of app same as you want:

    Step1@ take one int count=0 define globally.

    Step2@ when activity is called initially first question will be display with options.

    setValues(count); // here I am setting question and options to textview inside setValues named method.

    Step3@ onClick of NextButton check condition something like below:

    if (count == question.size() - 1) {
        finish();
        break;
    } 
    
    else {
    count++;
    setValues(count);
       }
    

    Step4@ onClick of PreviousButton check condition something like below:

    if (count <= 0) {
    Toast.makeText(OnPurposeUPSQuesAcitivty.this, "First Record",Toast.LENGTH_SHORT).show();
    break;
    } else {
    count--;
    setValues(count);
    }
    

    Your setValue method something look like below:

    public void setValues( int j) {
    txtque.setText(ques1.get(j));            
    
    btn_practice1.setText(answ1.get(j);
    btn_practice2.setText(answ1.get(j);
    btn_practice3.setText(answ1.get(j);
    btn_practice4.setText(answ1.get(j);
    }
    

    ………..

    Last Point@ After review your code, I don’t came across that how you are setting values to options.

    this

    btn_practice1.setText(answ1.get((k*4)+0));

    Will you explain above line of code, will update my answer, else you can use my solution as I mention above steps wise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have been unable to fix a problem with Java Unicode and encoding. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.