Reputation: 1470
I don't want the soft keyboard to appear when a particular EditText is touched. But I still want to be able to show the soft keyboard upon user request (say, when a button is pressed) and allow the user to edit the text. I know how to show/hide the soft keyboard, I only don't know how to prevent it from appearing on touch. Any suggestion how to do it?
The general idea is that the user will be mostly working with selection/position within the text, and only occasionaly entering characters. I don't want the visible amount of text to be reduced by the soft keyboard when selecting or navigating the text.
Upvotes: 3
Views: 1243
Reputation: 1472
Why don't you disable the edittext. Then it will not show keyboard on click. To this you can:
android:editable="false" //from xml
et.setEnabled(false); //from activity
And then on your buttonClick make it enable by setting above code true. And make your keyboard appear.
Also If you don't get the focus on edittext you can:
et.requestFocus(); // from activity
<EditText
android:id="@+id/et1"
android:editable="false"
android:layout_width="150dp"
android:layout_height="wrap_content" >
<requestFocus/>
</EditText>
//from xml
Hope this helps!
Upvotes: 0
Reputation: 1366
simply use
txtEdit.setShowSoftInputOnFocus(false);
and when you want to enable that , reverse above process
Upvotes: 3
Reputation: 161
Try the below code, it hides the keyboard:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
Upvotes: 0
Reputation: 13785
AndroidManifest.xml windowSoftInputMode
<activity android:name=".MyActivity" android:windowSoftInputMode="adjustPan"> </activity>
Upvotes: 0
Reputation: 161
within the activity in the manifest add the below code
android:windowSoftInputMode="adjustPan"
Upvotes: 0