The code logic for the progress bar is not displayed:
First, you create a new class that has an inner class that inherits from the inner class Therad
There is a common method in the class that calls the inner class in this method when the normal method executes.
At this point, the progress bar is displayed.
The progress bar is shown in the normal method, so the actual time shown is displayed after the internal class execution is completed, which of course is not possible.
Progress bar in sub-thread display is error, Baidu method tried not. How to do it.
Solution:
Create a common method in the class,
In the method, the child thread is directly new and start
The data results of the time-consuming operation are returned to handler by the handler message mechanism in the child thread
The handler receives the message and makes the corresponding processing.
Handler is a direct jump to activity. This is more important.
Some code shows:
Handler code:
Handler Handler = New Handler () {
@Override
public void handlemessage (Message msg) {
Super. Handlemessage (msg);
if(msg.What= =0) {
pb. Dismiss ();
String data = (string) Msg. obj ;
if(data.equals ("0")) {
Toast. maketext context "Verification failed, please re-login" ,toast. ). Show ();
Sqlitedao Sqlitedao = New Sqlitedao (context);
Sqlitedao.deletebbusinessdocumentlogin ();
}else {
Toast. maketext context "Validation succeeded" Toast. ). Show ();
Intent Intent = New Intent (context, ordergoods. class );
Context. StartActivity (intent);
}
}
}
};
The child thread returns the code sent to handler by the result set:
handler. Obtainmessage (0,returndata). Sendtotarget ();
Android sub-thread progress bar does not display issues