I don't know if you have ever encountered such a situation: the first time you created an APK interface, you wanted to display requestfocus () in a certain place to get the focus, but you couldn't call it directly, as shown in 1.
Figure 1 focus position
This phenomenon occurs when Android loads and refreshes the UI, in the order from left to right, from top to bottom. During the loading process, if requestfocus (findviewbyid (c) at this time )), if the interface is not refreshed yet, the requestfocus is invalid.
So I thought of a clever method. First, the asynchronous latency was about ms (the human eyes could not feel the changes within ms), and then requestfocus. I tried it and it was OK. The Code is as follows, if you have a better method, please contact me. Thank you.
New handler (). postdelayed (New runnable () {@ override public void run () {requestfocus (specific ID) ;}, 200 );
For Original Articles, please refer to blog.csdn.net/jjzhoujun2010 for reprinting.
Dream fly
When requestfocus cannot work immediately...