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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:17:27+00:00 2026-06-07T22:17:27+00:00

Im trying to make a simple quote app, but every time I hit my

  • 0

Im trying to make a simple quote app, but every time I hit my back button after my next button it will go to the next array and not backwards. Im using an int num to keep track of with quote the user is on.
here is my back button

package me.me.quote;


public class Startme extends Activity {
 Random gen= new Random();
int num;

 String[] quotes = new String[15];





public void next(View N){
         quotes[0]= "Love is timeless";
            quotes[1]= "I hate you";
            quotes[2]= "arggg!";
            quotes[3]= "The end is near";
            quotes[4]= "Leave be";

            if(num == 5){
                num =0;}



           TextView text = (TextView) findViewById(R.id.Quote);
           text.setText(quotes[num++]);



           TextView number = (TextView) findViewById(R.id.Qn);
            number.setText(""+num);

        }
public void back(View B){

 quotes[0]= "Love is timeless";
   quotes[1]= "I hate you";
   quotes[2]= "arggg!";
   quotes[3]= "The end is near";
   quotes[4]= "Leave be";

 TextView text = (TextView) findViewById(R.id.Quote);
 text.setText(quotes[num--]);

 TextView number = (TextView) findViewById(R.id.Qn);
    number.setText(""+num);}




  public void rand(View G)  {

 num = gen.nextInt(5);

  quotes[0]= "Love is timeless";
  quotes[1]= "I hate you";
  quotes[2]= "arggg!";
  quotes[3]= "The end is near";
  quotes[4]= "Leave be";
  TextView text = (TextView) findViewById(R.id.Quote);
  text.setText(quotes[num]);

TextView number = (TextView) findViewById(R.id.Qn);
number.setText(""+num);         
}


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.startquotes);

    TextView Dark=(TextView)findViewById(R.id.Quote); 
    Typeface face=Typeface.createFromAsset(getAssets(), "fonts/font1.ttf"); 
    Dark.setTypeface(face); 


}


}
  • 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-07T22:17:30+00:00Added an answer on June 7, 2026 at 10:17 pm

    //LAYOUT FILE text.xml

     <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
    
            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_alignParentTop="true"
                android:text="VISIBLE EVERY TIME"
                android:visibility="visible" />
    
            <Button
                android:id="@+id/back"
                android:layout_width="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView"
                android:text="NEXT" >
            </Button>
    
            <Button
                android:id="@+id/next"
                android:layout_alignParentRight="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView"
                android:text="BACK" >
            </Button>
    
        </RelativeLayout>
    

    ///ACTIVITY CLASS

     import android.app.Activity;
        import android.os.Bundle;
        import android.view.View;
        import android.view.View.OnClickListener;
        import android.widget.Button;
        import android.widget.TextView;
    
        public class Test extends Activity {
    
            Button next;
            Button back ;
            TextView quoteText;
            int currentSelectedQuote=0;
            String[] quote={"QUOTE1","QUOTE2","QUOTE3","QUOTE4","QUOTE5",};
    
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);
    
                setContentView(R.layout.text);
    
                quoteText=(TextView)findViewById(R.id.textView);
    
    
                quoteText.setText(quote[currentSelectedQuote]);
    
                 next=(Button)findViewById(R.id.next);
    
                 next.setOnClickListener(new OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
                        currentSelectedQuote++;
    
    
                        if(currentSelectedQuote == 5){
                            currentSelectedQuote =0;}
    
                        quoteText.setText(quote[currentSelectedQuote]);
    
                    }
                });
                 back=(Button)findViewById(R.id.back); 
    
                 back.setOnClickListener(new OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
    
                        if(currentSelectedQuote==0)
                        {
                            currentSelectedQuote=4;
                        }
                        else
                        {
                        currentSelectedQuote--;
                        }
    
                        quoteText.setText(quote[currentSelectedQuote]);
    
                        // TODO Auto-generated method stub
    
                    }
                });
    
    
    
    
    
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make simple minesweeper game in python, but have one problem. I have
I am fairly new to iOS development and trying make a simple app which
I'm trying to make a simple substring search using the brute force technique but
I am trying to make my app rotation friendly, but I am having some
Im trying to make a quite simple game but its having an error. I
I am trying to make a simple jquery slideshow, but I am not able
Trying to make a simple scroll to top button that smoothly scrolls up and
I am attempting to make a simple PhoneGap app that will allow a user
I'm trying to make simple website with content background combined from 3 images: top
I am trying to make simple notepad application for learning android development. So, to

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.