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

  • Home
  • SEARCH
  • 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 8985395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:19:14+00:00 2026-06-15T21:19:14+00:00

I’m kind of new when it comes to Android Application development and I’m developing

  • 0

I’m kind of new when it comes to Android Application development and I’m developing an app at the moment. I’m trying to get my TextView change every time the user clicks the Button(NEXT) and when another Button (PREVIOUS) gets clicked on I want it to change back to the original TextView. So basically I’d like to set up a certain amount of TextViews and be able to browse through them with the two Buttons I mentioned.

So far I only know how to make the the TextView change one time on a Button(NEXT) click. I’m using this piece of code for that:

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

    ImageButton Next = (ImageButton) findViewById(R.id.Next);
    Next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            TextView Text1= (TextView) findViewById(R.id.Text1);
            Text1.setText("New Text");  
        }
    });

NOTE: The Button “PREVIOUS” isn’t included yet because I didn’t know what to do with it yet.

I’m getting the feeling this code is only used when you want the TextView to change one time and you need a whole different method to make it change multiple times.

I hope I provided you with enough information and you are willing to help me out here.
Thanks in advance!

  • 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-15T21:19:15+00:00Added an answer on June 15, 2026 at 9:19 pm
    public class MyActivity extends Activity implements View.OnClickListener {
    
    int stringIdList[] = {R.string.text1, R.string.text2, R.string.text3, R.string.text4}
    int stringListCounter = 0;
    TextView text1;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
    
       ImageButton next = (ImageButton) findViewById(R.id.Next);
       ImageButton previous = (ImageButton) findViewById(R.id.Previous);
       text1 = (TextView) findViewById(R.id.Text1);
       Next.setOnClickListener(this);
       previous.setOnClickListener(this);
    }
    
    @Override
    public void onClick(View v) {
      int id = v.getId();
    
      if(id == R.id.Next && stringListCounter < stringIdList.length - 1) {
        stringListCounter++;
      } else if (id == R.id.Previous && counter > 0) {
        stringListCounter--;
      }
    
      Text1.setText(stringIdList[stringListCounter]);
    }
    

    What this does is assigns your Activity to an OnClickListener to handle the click events. If Next was pressed and the counter is within the range of the array list, it will increase the counter. The same for previous. At the end of the click, it will set the text to whatever the ID is. This assumes your strings are in a strings.xml file which is recommended in the Android spec and is static.

    • 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.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
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
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.