==================== Problem Description ====================
I want to update textview content dynamically, but nothing happens. There is no relevant code.
==================== Solution 1====================
Write a timer. or write a thread. It's time to update it in the interval.
==================== Solution 2====================
Reference 2 floor Tyaathome's reply:
Quote: Quote 1 floor peijiangping1989 reply:
Write a timer. or write a thread. It's time to update it in the interval.
There is no similar code example for me to look at.
Create a new thread to update the values inside the TextView, and then use handler to update the interface!
==================== Solution 3====================
Class Testthread extends thread{public void run () {Message message = new Message (); Mhandler.sendmessage (message); }}//Update in Handler uiprivate Handler mhandler = new Handler () {public void Handlemessage (Message msg) {text View.settext ("You want to change the content"); }; };
And then in your code, execute this thread
==================== Solution 4====================
private final timer timer = new timer (); private timertask Task; handler handler = new handler () { @Override public void handlemessage (message msg) { // TODO Auto-generated method stub textview.settext ("XXXX"); Super.handlemessage (msg); }};task = new timertask () { @Override public void run () { // TODO Auto-generated method stub message message = new message (); message.what = 1; Handler.sendmessage (message); } }; timer.schedule (task, 1000, 1000);
Or that's fine.
==================== Solution 5====================
Mtestingbutton.setonclicklistener (New Onclicklistener () {
public void OnClick (View v) {
To begin the testing of Open-short.
Testdialog = Progressdialog.show (Initmassage.this, "", "Don t touch the Screen,open-short testing ...", true, false);
TimerTask task = new TimerTask () {
public void Run () {
Execute the Task
Testdialog.cancel ();
Mshorttestno.settext ("Pass");
System.out.println ("1");
}
};
Timer timer = new timer ();
Timer.schedule (task, 6000);
System.out.println ("2");
}
});
I use the above why cannot change the value of TextView after delay 6s to "Pass", the system will automatically crash!
How do I dynamically update the content of TextView in Android development?