Android ListView navigates to the specified line while hiding the input keyboard

Source: Internet
Author: User

Help others the bug encountered a problem, recorded.


listView.setSelection(a);
This method allows you to position your listview to the specified line

However, if the code that hides the input keyboard is executed immediately, there will be a bug, and this time the location cannot be implemented.

                    imm.hideSoftInputFromWindow(PatientAddActivity.this                            .getCurrentFocus().getWindowToken(),                            InputMethodManager.HIDE_NOT_ALWAYS);

Using the toggle method to hide the input keyboard will have no effect:

imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

Android ListView navigates to the specified line while hiding the input keyboard

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.