Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView contents update

I have a programmatically generated ScrollView with a TextView inside of it. I wish to update the text in the TextView from time to time and some have implemented a handler function to update the TextView GUI element. This seems to call/work correctly.

However, currently the only way I have found to actually get the TextView to show the appended information is to call:

consoleText.append("New text to add to TextView");
// then:
myScrollView.removeView(myTextView);
myScrollView.addView(myTextView);

This is not particularity optimal and was wondering how else I can refresh the contents of the ScrollView to show my newly added information...

Also:

invalidate();
postvalidate();

Do not seem to do anything - the TextView object has the new text in it (looking in debug) it's just not drawing it to the screen unless I call the add/remove function.

Thanks for any information/help you can give

FR

like image 226
FiniteRed Avatar asked Aug 07 '12 11:08

FiniteRed


1 Answers

You should call invalidate() and requestLayout() on the TextView, and perhaps the ScrollView.

like image 160
Samuel Avatar answered Nov 08 '22 00:11

Samuel