I'm in a fragment1
Perform button key event, need to refresh the contents of the textview
About the following
BtnC. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v)
{
Textview1. Settext="1111111";
//a
Textview1. Settext="2222222";
//a
Textview1. Settext="3333333";
//a
Textview1. Settext="4444444";
}
In fact, the above code implementation, button interface feign death, textview1 displays only the last of the "4444444"
So I add the following code
HandlerThread HandlerThread;
Private static String="" TT;
The class HandlerThread extends Thread
{
Handler mHandler;
HandlerThread Handler (h)
{
MHandler=h;
}
Public void the run ()
{
Byte status;
The Message MSG.
While (true)
{
Try
{
Thread.sleep (100);
}
Catch InterruptedException (e) {e.p rintStackTrace (); }
{
MSG=handler. ObtainMessage (0, "");
MHandler. SendMessage (MSG);
}
}
}
}
Final Handler Handler=new Handler ()
{
Public void handleMessage (Message MSG)
{
The switch (MSG. What)
{
Case 0:
If (TV. Length () & gt; 0)
{
Textview1. SetText (TV);
}
break;
Default:
break;
}
}
};
BtnC. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v)
{
TT="1111111";
//a
TT="2222222";
//a
TT="3333333";
//a
TT="4444444";
}
Add
in onCreate
HandlerThread=new handlerThread (handler);
HandlerThread. Start ();
Still no
Only see the last show of "44444444"
Refresh too fast?
Or what reason?
CodePudding user response:
The