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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:24:36+00:00 2026-06-02T19:24:36+00:00

I’m fairly new to programming for android and I’m having trouble updating a TextView

  • 0

I’m fairly new to programming for android and I’m having trouble updating a TextView in my code. I am able to set it and it updates properly from onResume().

Later, I call

startActivityForIntent(my.android.activity,0)

I then use setText in this method:

onActivityResult(int requestCode, int resultCode, Intent returnIntent){
    if (resultCode == Activity.RESULT_OK){
        String myString= returnIntent.getString("mystr","empty");
        myClass=myClass.interperetResults(myString);  //this method returns correctly
        leftText.setText(""+myClass.toString());
        leftText.invalidate() //neither invalidate() or postInvalidate() changes result
    }
};

and it appears updated inside the TextView class (I’ve used System.out to debug this), but it does not update on the screen.

From what I can tell, I just need to call TextView.invalidate() or TextView.postInvalidate(), neither of which are effective. Is there something I’m missing, or what? I’ve tried many of the different suggestions from other posts, to no avail here.

I also have a rightText object and if statements for when the returned string is null, but this is the section I’m having issues with. If you guys need any other parts of my code, please let me know. I’d be more than happy to help. Thanks again for your input.

EDIT: As requested, here is my xml layout. Though the problem isn’t me not being able to see the view. When I call setText in onResume() it displays and changes properly. Anyway, here’s my xml code. I don’t feel like changing the variable names to generic things, so this is what it actually is. I’m working with a partner on the project, and he’s the one who created the xml and layout, so I’m not entirely sure what everything here is. I hope you guys can make sense of it.

Here’s onCreate:

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

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

}

And onResume:

protected void onResume() {
    super.onResume();
    // The activity has become visible (it is now "resumed").
    setContentView(R.layout.play);

    myEquation = new Equation(getResources());
    leftText = (TextView) this.findViewById(R.id.playLeftEquation);
    rightText = (TextView) this.findViewById(R.id.playRightEquation);

    //leftText.setText("No data");
    //rightText.setText("No data");  //The textviews update fine here.  
               //Currently commented out because I thought that maybe this was 
               //overwriting the other setText, but still no change.

}



<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/atomic_bckgrd"
    android:columnCount="11" >
    <ImageButton    
        android:id="@+id/playTrashCanButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_columnSpan="2"
        android:layout_gravity="left"
        android:layout_row="0"
        android:contentDescription="@string/trash"
        android:onClick="clickHandler"
        android:src="@drawable/trash" />

    <Button
        android:id="@+id/playEditButton"
        android:layout_column="2"
        android:layout_row="0"
        android:onClick="clickHandler"
        android:text="@string/edit" />

    <ImageButton
        android:id="@+id/playRulesButton"
        android:layout_column="4"
        android:layout_columnSpan="5"
        android:layout_row="0"
        android:contentDescription="@string/rules"
        android:onClick="clickHandler"
        android:src="@drawable/rules1" />

    <TextView            //One of the non-updating fields
        android:id="@+id/playLeftEquation"
        android:layout_column="1"
        android:layout_gravity="bottom"
        android:layout_row="1"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ImageButton
        android:id="@+id/playEnterButton"
        android:layout_column="2"
        android:layout_gravity="bottom"
        android:layout_row="1"
        android:contentDescription="@string/enter"
        android:onClick="clickHandler"
        android:src="@drawable/enter1" />

    <TextView               //The other non-updating field
        android:id="@+id/playRightEquation"
        android:layout_column="3"
        android:layout_columnSpan="6"
        android:layout_gravity="bottom"
        android:layout_row="1"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <Space
        android:layout_width="52dp"
        android:layout_height="1dp"
        android:layout_column="0"
        android:layout_row="0" />

    <Space
        android:layout_width="148dp"
        android:layout_height="1dp"
        android:layout_column="1"
        android:layout_row="0" />

    <Space
        android:layout_width="161dp"
        android:layout_height="1dp"
        android:layout_column="2"
        android:layout_row="0" />

    <Space
        android:layout_width="46dp"
        android:layout_height="1dp"
        android:layout_column="3"
        android:layout_row="0" />

    <Space
        android:layout_width="36dp"
        android:layout_height="1dp"
        android:layout_column="4"
        android:layout_gravity="fill_horizontal"
        android:layout_row="0" />

    <Space
        android:layout_width="1dp"
        android:layout_height="160dp"
        android:layout_column="0"
        android:layout_gravity="fill_horizontal"
        android:layout_row="0" />

</GridLayout>
  • 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-02T19:24:36+00:00Added an answer on June 2, 2026 at 7:24 pm

    FIXED:
    I have figured out the problem. After removing the toString method from myEquation to see the addresses used, I realized that I was initializing myEquation in onResume(). (I had actually moved it to onStart() by this point, but that had the same effect)

    So yeah. Initialize all your variables in onCreate() and avoid massive headaches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
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&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
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 have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

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.