Android:view after swapping, unable to set focus correctly or after switching TextView the virtual keyboard does not eject

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.