Android: problem with EditText.settext()
I have a viewflipper. One of its views has 3 Buttons (a, b, c) and 3 EditTexts. Whenever a Button is clicked, the first Textedit should show the text of the clicked Button and the cursor should jump to the next EitText. After clicking the third Button, the third EditText (the last one) should show the text and then viewflipper.showNext() should be run.
The Problem: After clicking the third Button, if I put showNext() after EditText.setText() the EditText doesn't show the text but If there is no showNext() after EditText.setText() it shows the text. I t开发者_如何学编程hink showNext() runs before the text appears on editText. How can I prevent that?
please help!
So it sounds like you want to delay the running of the viewFlipper.ShowNext() until the after EditField3.setText() happens.
I would use a Handler run the code block delayed by 0.5 seconds or so (be sure to test on a device and not just the emulator).....
Handler handler = new Handler();
Runnable r=new Runnable()
{
public void run()
{
viewFlipper.showNext();
}
};
handler.postDelayed(r, 500); // In ms
精彩评论