Android中的EditText默認時不彈出軟鍵盤的方法


方法一:
  在 AndroidMainfest.xml中選擇哪個activity,設置windowSoftInputMode屬性為 adjustUnspecified|stateHidden

1 <activity android:name=".Main"
2       android:label="@string/app_name"
3       android:windowSoftInputMode="adjustUnspecified|stateHidden"
4       android:configChanges="orientation|keyboardHidden">
5   <intent-filter>
6       <action android:name="android.intent.action.MAIN" />
7       <category android:name="android.intent.category.LAUNCHER"/>
8   </intent-filter>
9 </activity>

 

方法二:

    讓 EditText失去焦點,使用EditText的clearFocus方法

EditText edit = (EditText)findViewById(R.id.edit);
edit.clearFocus();

 

方法三:

    強制隱藏Android輸入法窗口

EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM