當初解決這個問題時在網上搜索了好多解決方案但都無法解決問題
軟鍵盤仍會彈出,現分享本熊的解決方法
- 在AndroidManifest.xml檔案中找到不想彈出軟鍵盤的那個activity
- 在那個activity標簽中添加android:windowSoftInputMode="stateHidden|stateAlwaysHidden"注意添加位置,添加在標簽內
<activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden|stateAlwaysHidden"> - 在對應的Java檔案中插入
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //阻止鍵盤彈出
text.setShowSoftInputOnFocus(false);
}
text替換為你的EditView變數名
此方法適用于Android 5.0及以上版本(為什么沒寫5.0以下的哪,畢竟很少有人在用了(●’?’●))
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/251798.html
標籤:其他
