Android go to title
Add the following statement before setcontentview (R. layout. activity_main) of the activity.
Requestwindowfeature (window. feature_no_title );
You cannot enable network connection in the main thread for Android 4.0 or later. Otherwise, an exception is thrown. You need to obtain network data in the Child thread.
Handler has restrictions on the returned data. The simplest way is to define a global variable. assigning values to global variables can solve the problem. Of course, this method may have some side effects. I am not very clear about the specific side effects.
New thread (New runnable (){
@ Override
Public void run (){
Try {
Newes = newsservice. getjsonlastnews (); // the most time-consuming function. newes is defined as a global variable to return data.
} Catch (exception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
Message MSG = new message ();
Handler. sendmessage (MSG );
}
}). Start ();
Handler = new handler (){
@ Override
Public void handlemessage (Message MSG ){
// Process data in the middle
}
};