Android does not now support view creation and invocation of its methods in child threads. If you want to implement the sub-thread content update, feedback the results to the main thread in a timely manner, how to come out?
You can create handler in the main thread to implement it. As a result of this thread, you can notify the main thread by sending a message, and then update the view control in the main thread in a timely way.
How to use handler:
Mhandler = new Handler () {
@Override
public void Handlemessage (Message msg) {
Super.handlemessage (msg);
Switch (msg.what) {
Case XXXXXX:
Updatelotteryinfo ();
Break
Default
Break
}
}
};
When you send a message, you can: Mhandler.sendemptymessage (xxxxx);
If you add content, you can: Mhandler.obtainmessage (MessageName, messagecontent). Sendtotarget ();
In method Handlemessage, you can get the contents of the message msg.obj.toString ().
There are other ways to send a message and you can check it yourself.