Android Fragment: the soft keyboard after UserDictionaryAddWordFragment is edited when a large screen tablet is developed

Source: Internet
Author: User

I received a bug yesterday, which is described as follows: 1 Enter Settings --> Language & input2 Choose personal dictionary3.Choose add in menu4.Input some word and choose personal dictionary [Expected result] The word can be added to dictionary and no any error [Error] The input panel can't hide enter add user dictionary, edit and exit, however, the input panel cannot be automatically hidden. This issue involves the concept of fragment. For more information about the concept of fragment, see http://www.cnblogs.com/mybkn/articles/2455134.html. The user dictionary is added in UserDictionaryAddWordFragment. UserDictionaryAddWordFragment inherits from Fragment. \ Packages \ apps \ Settings \ src \ com \ android \ settings \ inputmethod \ UserDictionaryAddWordFragment. java adds the following code in its onPause () method: boolean autoHide = getResources (). getBoolean (R. bool. auto_hide_keyboard_when_onpause); if (autoHide) {www.2cto.com ContexttContext = getActivity (); InputMethodManager imm = (InputMethodManager) getActivity (). getSystemService (tContext. INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow (GetActivity (). getCurrentFocus (). getWindowToken (), 0);} R. bool. auto_hide_keyboard_when_onpause bool value under \ packages \ apps \ Settings \ res \ value. it is defined in xml. The value of smart-phone is false, and the value in bool. xml under the value-sw600dp directory is true. The onPause method of Fragment is called when this Fragment is invisible. Therefore, you can add this code to the onPause method to automatically hide the input method interface when exiting this Fragment.

Related Article

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.