Android disables soft keyboard popup automatically

Source: Internet
Author: User
<span id="Label3"></p><p><p>Android system to edittext this control has a monitoring function, if an activity contains the control, it will automatically eject the soft keyboard to let you enter, this seemingly human-like scheme is sometimes not liked by users, so in some cases to disable the Feature. These days to do the application also has this problem, so check, most of the online is the following method:</p></p><pre><activity android:name=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">. Mainactivity</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">android:screenorientation</span></span>=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">Landscape</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">color: #ff0000;</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>>android:windowsoftinputmode=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">Adjustpan|statehidden</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span></span> <span style=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">color: #ff0000;</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>>android:configchanges=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">orientation|keyboardhidden</span></span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>> <intent-filter> <action android:name=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">Android.intent.action.MAIN</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>/> <category android:name=<span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">Android.intent.category.LAUNCHER</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>/> </intent-filter> </activity></pre><p><p>This method is really useful, but only in this activity can play around, if the activity in the TAB function of the switch, the soft keyboard will bounce out, so the following workaround:</p></p><p><p>Add a hidden TextView to the XML file:</p></p><pre><pre> <<span style="color: #000000;">textview android:id </span> =<span style="color: #800000;"> "</span> <span style="color: #800000;">@+id/config_hidden </span> <span style="color: #800000;" "< span> <span style=" color: #000000; "> android:layout_ Width </span> =<span style="color: #800000;" "< span> <span style=" color: #800000; ">wrap_content </span> <span style="color: #800000;"> "</span> <span style=" color: #000000; "> android:layout_height </span> =<span style=" color: #800000; ">" </span> Span style= "color: #800000;" >wrap_content </span> <span style="color: #800000;" "< span> <span style=" color: #000000; "> android:focusable </span> =<span style="color: #800000;" "< span> <span style=" color: #800000; ">true </span> <span style=" color: #800000; "> "</span> <span style=" color: #000000; "> android:focusableintouchmode </span> =<span style=" color: #800000; ">" </span> <span style="color: #800000;">true </span> <span style="color: #800000;"> "</span>/> </span></span></span></pre></pre><p><p>Then add in the Activity:</p></p><pre><pre><span style="color: #0000ff;"></span>this. Findviewbyid (r.id.config_hidden);</pre></pre><pre><pre>Config_hidden.requestfocus ();</pre></pre><p><p>This will not eject the soft Keyboard.</p></p><p><p>Android disables soft keyboard popup automatically</p></p></span>

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.