Android TextView setText not updating text
I have an app which uses view flippers for different tabs. On one tab I have the main flipper, which is displayed when the app is launched. This contains a list view. Objects in the list view then have a detail page which is displayed when clicking on them.
I have a second tab called favourites, which allows the user to add these list objects to the favourites list. Clicking on an item in the favourites list brings the user to the same detail page as 开发者_JAVA百科in the main flipper.
In this detail page, there is a text view, which shows the title of the object selected. This text view displays fine when viewing it from the main flipper but doesn't seem to work when selecting an item in the favourites list.
I have done a textView.getText() and it displays the correct text in log cat but the user can't actually see this text displayed in the app.
What could be causing this? Here's the code which is run when the user selects an item in the favourites list.
nameText = null;
nameText = (TextView) findViewById(R.id.nametext);
nameText.setText(fetchName());
Log.v(LOG_TAG,"nameText equals:" + nameText.getText());
flipper.showNext();
Thanks in advance.
Check if the setTex method is actually executed in the Gui thread.
Use nameText.post to execute operatios in the Gui thread.
More about threads in android: http://developer.android.com/resources/articles/painless-threading.html
Greetings
精彩评论