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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:30:15+00:00 2026-05-24T16:30:15+00:00

I have 3 classes: main, Sublist and editcrap. For now i have 2 textviews

  • 0

I have 3 classes: main, Sublist and editcrap.

For now i have 2 textviews separated by a Button in the Sublist xml file; and an EditText and a Button in my editcrap xml file.

What i wanted to do was take text input from the EditText in the editcrap activity, click the Button and return it to the Sublist activity and display it in the 1st textview of the Sublist xml file. I’ve done this using Intents and startActivityForResult() from the Sublist actvity.

The problem:

But after receiving data bak in the Sublist activity; after the “subject1.setText(newText);” code is executed…all i see in the Sublist activity in the emulator is the Button (that was supposed to be in between the 2 TextViews) and the TextView on the right. The left TextView vanishes. No error on emulator or nothin…just the TextView vanishes. I’ve been tryin to get around this but no luck. Could someone tell me wat i’m overlooking? 🙂

my code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode)
    {
        case 1: if(resultCode==Activity.RESULT_OK)
        {
            String newText = data.getStringExtra("thetext");
            subject1.setText(newText); 
            // this is where the textview supposed to update but 
            // instead vanishes entirely
        }
    break;
    }
}

//second activity's code:

sub1 = (EditText) findViewById(R.id.peditText1);    
final String theText = sub1.getText().toString();
parambutton1 = (Button) findViewById(R.id.parambutton1);

parambutton1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent i = new Intent(editcrap.this, Sublist.class);

            i.putExtra("thetext", theText);
            setResult(Activity.RESULT_OK, i);
            finish();

        }
    });
}

this is how the second activity returns the input text from the EditText.

  • 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-05-24T16:30:15+00:00Added an answer on May 24, 2026 at 4:30 pm

    Per the documentation, always use extra names prefixed with your package’s name.

    Ex: "com.example.thetext"

    Example set result:

    data.putExtra("com.example.thetext", yourstring);
    setResult(Activity.RESULT_OK, data);
    

    Example get result:

    String newText = data.getStringExtra("com.example.thetext");
    subject1.setText(newText); 
    

    To avoid mistyping the extra field name, I use string resources so I can do getString(R.string.extra_thetext) which stores “com.example.thetext” for me so I don’t mistype it later (isn’t compile-time checking great?). But you can similarly use a constant :

    static final String THE_TEXT = "com.example.thetext";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file called main.py and a file called classes.py main.py contains the
I have 2 classes within same package. Both classes have main method in them.
I have 2 classes, main and extended. I need to use main vars in
I have 3 classes in my example: Class A, the main activity. Class A
I have two classes orchestrated by a main class and I would like to
I have a single maven project that has multiple main classes. I want to
I currently have 3 classes, a main class containing a GUI, and the fnameTxtField
i working on a c++ string library that have main 4 classes that deals
Right now I have classes like: abstract class Record { // Required fields val
I have 3 classes named maths, alphabets and main. The Maths Class contains Add

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.