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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:06:12+00:00 2026-06-15T02:06:12+00:00

simple program: 2 buttons (previous/next) and a textview to show text. by intent I

  • 0

simple program: 2 buttons (previous/next) and a textview to show text.

by intent I created an Index (inside a method)

private void index(){
    Intent i = new Intent(this, Index.class);
    startActivityForResult(i, 1);
}

Index.class (with 3 buttons):

button1.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {   
        String result = "1";
        Intent returnIntent = new Intent();
        returnIntent.putExtra("result",result);
        setResult(RESULT_OK,returnIntent);     
        finish();
    }
});

Main.class

String value = "1";
final String prog1[] = new String[16];
final String prog2[] = new String[105];
final String prog3[] = new String[66];

int a;
int b;
int c=3;

int array1start = 0; int array1end = 15;
int array2start = 0; int array2end = 105;
int array3start = 0; int array3end = 65;



@Override
public void onCreate(Bundle savedInstanceState){ 
  super.onCreate(savedInstanceState);


if (value.equals("1")){

        a = array1start;
        b = array1end;
        prog=prog1; 

    }
    else if (value.equals("2")){
        a = array2start;
        b = array2end;
        prog=prog2; 

textView1.setText(""+prog[a]);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 1) {

         if(resultCode == RESULT_OK){

          String result=data.getStringExtra("result");
          value=result;
          Toast toast2=Toast.makeText(this,"value: "+value,Toast.LENGTH_LONG);
          toast2.show();
    }

    if (resultCode == RESULT_CANCELED) {
         //Write your code on no result return 

    }}
    }//onAcrivityResult

at this point, choosen choice in index class should be change a result string to “value” string in main class

private void index(){


    Intent i = new Intent(this, Index.class);
    startActivityForResult(i, 1);



}

my textview take data from array1 or array2 by index class

so, I dont’ understand how update textview (because index value is correct).

thanks for the help

  • 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-15T02:06:14+00:00Added an answer on June 15, 2026 at 2:06 am

    Put you code into function onActivityResult

    if (value.equals("1")){
    
            a = array1start;
            b = array1end;
            prog=prog1; 
    
        }
        else if (value.equals("2")){
            a = array2start;
            b = array2end;
            prog=prog2; 
    
    textView1.setText(""+prog[a]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple program with one TextView and two Buttons: Button1 and Button2.
I have a simple program that checks webpages for strings, example: Private Sub Button1_Click(ByVal
I'm writing a simple program to convert text to strings. One quick question, how
I have a java program that has so many buttons with a text on
I'm trying to develop a simple program which will show a form with a
I'm working on a simple java GUI program with two buttons and a displayed
A simple iphone program generated by project template View-based Application, with several buttons, and
I am doing some simple program in Qt (MSVC++2008) with few checkboxes and buttons.
I want to make a simple counter program where I have a Textview and
I've created a basic program that uses radio buttons, buttons and check boxes. My

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.