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 8624159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:27:20+00:00 2026-06-12T07:27:20+00:00

I’m making my first android app and I want to to make a test

  • 0

I’m making my first android app and I want to to make a test app, I’m using a variable and “If”/”Else if” statements in order to change the text of the question (TextView) and answers (RadioButtons). The problem is that when the user presses the button for the first time the answers and question change but when the user press the button for the second time the question and answers don’t change and I don’t know why…

Here is my activity:

package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class Test extends Activity {

TextView titulo;
RadioGroup buttons;
RadioButton opcn1;
RadioButton opcn2;
RadioButton opcn3;
RadioButton opcn4;

int pregunta = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.memetest);

    titulo = (TextView) findViewById(R.id.textView1);

    buttons = (RadioGroup) findViewById(R.id.radioGroup1);

    opcn1 = (RadioButton) findViewById(R.id.radio0);
    opcn2 = (RadioButton) findViewById(R.id.radio1);
    opcn3 = (RadioButton) findViewById(R.id.radio2);
    opcn4 = (RadioButton) findViewById(R.id.radio3);


    Button siguiente = (Button) findViewById(R.id.siguiente);
    siguiente.setOnClickListener(new OnClickListener() {


        @Override
        public void onClick(View v) {

            pregunta = + 1;

            if (pregunta == 1){ 

                titulo.setText(getString(R.string.Q2));
                opcn1.setText(getString(R.string.Q2O1));
                opcn2.setText(getString(R.string.Q2O2));
                opcn3.setText(getString(R.string.Q2O3));
                opcn4.setText(getString(R.string.Q2O4));

            }
            else if (pregunta == 2){

                titulo.setText(getString(R.string.Q3));
                opcn1.setText(getString(R.string.Q3O1));
                opcn2.setText(getString(R.string.Q3O2));
                opcn3.setText(getString(R.string.Q3O3));
                opcn4.setText(getString(R.string.Q3O4));

            }
        };

    });
}
}

I tried using “break” but the problem persists.

Help, please.

  • 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-12T07:27:21+00:00Added an answer on June 12, 2026 at 7:27 am

    To add 1 to your variable on each click event, try using this instead:

    pregunta++;
    

    (Understand this is the same as pregunta += 1; or pregunta = pregunta + 1;)


    What you wrote pregunta = + 1; means pregunta = +1; which is nothing more than

    pregunta = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.