-1

I have a simple screen created in xml, the parent layout is a "relativelayout" and i have a child layout (who is also a "RelativeLayout" containing 3 textview inside).

the only thing I have to do is press a button and change the values ​​of textviews.

to change the text is obviously this:

MyTextView.SetText("Text");

the code runs perfectly, but does not refresh the text of the textviews in the layout.

but when the screen is rotated, the screen refreshes, and the label gets the correct value.

Why does this happen? Why when pressing the button I can not update the text?

I tried using "AsyncTask" and the text is not updated either.

Did something simple can be so problematic. ?

greetings.

Goo
  • 1,318
  • 1
  • 13
  • 31
seba123neo
  • 4,688
  • 10
  • 35
  • 53
  • 1
    plz show some of ur code......... – c2dm Jun 29 '12 at 02:47
  • possible duplicate of [Restoring state of TextView after screen rotation?](http://stackoverflow.com/questions/5179686/restoring-state-of-textview-after-screen-rotation) – K_Anas Jun 29 '12 at 04:20
  • the "layout" is not updated/refreshing after assigning the text to a textview why? I tried to update a "textview" which is "outside" of the layout and updated fine. Why? – seba123neo Jun 29 '12 at 14:06

1 Answers1

2

Your code

MyTextView.SetText("Text");

Should be executed on UI thread to give effect say suppose if you want it to be updated after button click then this code should be inside your onClickButton listener of your button

Visit This Link for more details

Community
  • 1
  • 1
RPB
  • 16,006
  • 16
  • 55
  • 79
  • Hi, I know that, but here the problem is that I can not update the text of a TextView inside a layout, I tried to update the text of a TextView that is "outside" the layout and it works fine, why? – seba123neo Jun 29 '12 at 13:50
  • the button is inside a AlertDialog. – seba123neo Jun 29 '12 at 19:39
  • You can use just Dialog and add the content to it having your own button and then you can prevent it from closing dialog and close dialog whenever you want. :) – RPB Jun 30 '12 at 04:47