While learning and testing, it took three days to complete a small application.
A lot of problems were encountered, but eventually they were solved.
My phone is Android2.2 version, so I also in the 2.2 version of the environment to learn, development.
1. When switching interfaces in different view (layout) in the same activity, TextView often fails to get the focus correctly.
Or more seriously, with the focus, but after the click, the virtual keyboard does not eject, simply cannot enter the data normally.
I spent three hours trying to solve the problem of the focus and the virtual keyboard not popping up last night.
The Final Solution:
When switching from View1 to View2:
Setcontentview (VIEW2);
View v = getcurrentfocus ();
if (v!=null)
{
V.clearfocus (); Clear the original focus
}
Tnumber.requestfocus (); Take the focus
I saw someone on the internet saying that when you execute to Setcontentview (), the interface is not drawn immediately, and when the interface is not finished, it is immediately executed to the Requestfocus (), so the focus cannot be achieved properly.
The most fundamental reason is what, I really do not know, I am Android rookie ...
2011-11-24
Android:view after swapping, unable to set focus correctly or after switching TextView the virtual keyboard does not eject