Bal*_*i.K 16 android android-softkeyboard
每当我点击EditTextAndroid键盘弹出窗口出现,但我不想弹出键盘.
我想永久隐藏我当前应用程序的Android键盘弹出窗口.
我怎样才能做到这一点?
And*_*psa 29
设置标志textIsSelectable以true禁用软键盘.
您可以在xml布局中设置它,如下所示:
<EditText
android:id="@+id/editText"
...
android:textIsSelectable="true"/>
Run Code Online (Sandbox Code Playgroud)
或者以编程方式,像这样:
EditText editText = (EditText) findViewById(R.id.editText);
editText.setTextIsSelectable(true);
Run Code Online (Sandbox Code Playgroud)
光标仍然存在,你可以,select/copy/cut/paste但软键盘永远不会显示.
小智 12
您可以尝试使用如下按钮伪造您的EditText:
<Button
android:id="@+id/edit_birthday"
style="@android:style/Widget.EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_birthday"/>
Run Code Online (Sandbox Code Playgroud)
Sol*_*ety 10
在清单中:
<activity
android:name=".YourActivity"
.
.
.
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
Run Code Online (Sandbox Code Playgroud)
解决方案可以在这里找到:
public void onCreate(Bundle savedInstanceState) {
edittext = (EditText) findViewById(R.id.EditText01);
edittext.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event != null&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
in.hideSoftInputFromWindow(edittext.getApplicationWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
}
return false;
}
});
}
Run Code Online (Sandbox Code Playgroud)
适用于所有 Android 版本。
在您的 XML 中使用属性 android:textIsSelectable="true"
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
.
.
.
android:textIsSelectable="true"/>
Run Code Online (Sandbox Code Playgroud)
并且,在您的 Java 类中:
editText1.setShowSoftInputOnFocus(false);
Run Code Online (Sandbox Code Playgroud)
在科特林:
editText1.showSoftInputOnFocus = false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21530 次 |
| 最近记录: |