Reputation: 1676
I'm using a hidden EditText (visibility is not set to invisible, but rather the EditText has 0dp width and height) to receive user input. I'm using the input data to fill other TextViews. The reason i'm doing this is because I don't want the visible forms (the TextViews) to have the same properties as an actual EditText, but I do want to use the Soft Keyboard.
My problem is that when the user chooses to hide the keyboard, either by pressing back or the 'done' button, I want to make it reappear when they click on a TextView, so that they once again can start editing the hidden EditText.
I've tried the following code, with no success:
if(hiddenEt.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
The code within the if-statement does run, but the Soft Keyboard doesn't reappear.
Is there a separate function for actually calling the Soft Keyboard?
Upvotes: 1
Views: 1498
Reputation: 1610
InputMethodManager imm=(InputMethodManager)getSystemService(yourActivity.this.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
Add android:windowSoftInputMode="stateVisible|adjustResize|adjustPan"
in your manifest file.
<activity
android:name=".yourActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustResize|adjustPan" >
</activity>
Upvotes: 0
Reputation: 24853
Try the following code inside textview's on click..
hiddenEt.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(hiddenEt, InputMethodManager.SHOW_IMPLICIT);
Upvotes: 1