1

Hi I wrapped edittext control onto a control that is being displayed on the screen at users request. It overlays the whole screen until user presses 'done' button on the keyboard.

I am not able to explicitly show the control on the screen. only when user taps into control only then its shown. Am I missing something?

I even try this and it does not brin it up when I launch the overlay that Edit Text exists on:

customCOntrol.showKeyboard();

public void showKeyboard()
    {
        InputMethodManager imm = (InputMethodManager)_context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(this._textView.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);
    }

here is the settig I have on the screen itself in the config file android:windowSoftInputMode="stateHidden|adjustPan"

Thank you in advance

dropsOfJupiter
  • 6,763
  • 12
  • 47
  • 59

3 Answers3

9

In your showKeyboard function you are calling:

 imm.hideSoftInputFromWindow(this._textView.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);

This will hide the softInput keyboard from the window! Do you want to show the keyboard? If yes then would you use:

 imm.showSoftInput(view, flags, resultReceiver);

EDIT: I think you can also toggle the keyboard from the InputMethodManager, try:

 imm.toggleSoftInput(0, 0);
iamreptar
  • 1,461
  • 16
  • 29
Kenny
  • 5,522
  • 2
  • 18
  • 29
  • 2
    thank you toggleSoftInput(0, 0) worked. I can't believe the mental error I made with hide :) The first one did not work btw. – dropsOfJupiter Jun 29 '11 at 00:57
  • one question, the keyboard is up but the focus of the control is not thee, so the user still need to tap into the edittext. how do I make edittext to have the flashing indicator? – dropsOfJupiter Jun 29 '11 at 01:03
  • 1
    Another question I have is how to do the same (bring the keyboard) directly on the screen. It does not seem to work. Keyboard comes up for a second or two and then disappears. Not sure what's causing it. – dropsOfJupiter Jun 29 '11 at 19:19
0

@dropsOfJupiter

You can do: editText.requestFocus() as you launch the Activity or Fragment containing your EditText reference. This will give the focus to the EditText and will bring uo the SoftKeyboard.

I hope this helps.

Lazycoder-007
  • 1,055
  • 9
  • 19
0

PROBLEM:

I faced with this keyboard not showing up problem. I wrote the following solution inspired by this answer but not their solution! It works fine. In short the reason for this mess is that the request focus and the IMM provided service can only run on a view that is created and active. When you do all these on the creation phase onCreate(Bundle savedInstance).. or onCreateView(LayoutInflater inflater... and the view is still in initializing state, you won't get an active view to act on! I have seen many solutions using delays and checks to wait for that view to get active then do the show keyboard but here is my solution based on the android frame work design:

SOLUTION:

in your activity or fragment override the following make sure your view has the access (define it in the top of the activity/fragment):

@Override
public void onStart() {
    yourView.requestFocus();
    showSoftKeyboard(yourView);
    super.onStart();
}
public void showSoftKeyboard(View view) {
    if(view.requestFocus()){
        InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view,InputMethodManager.SHOW_IMPLICIT);
    }
}
Araz
  • 151
  • 2
  • 11