0

OK I have an array of EditTexts, and I want to loop through them, so if some EditText does not contain text, I want to ask user for input, and I'm through a lot of hours and a lot of reading but I can not understand how this is supposed do work. So few questions:

Is requestfocus() enough ? (It's not working - keyboard does not show)

I have tried with OnFocusChangeListener and than tried to Show keyboard (showSoftInput(view,InputMethodManager.SHOW_IMPLICIT)) if there is focus on editText again it is not working.

Does anyone know of any good example to get me out of this triangle?

Adnan Pirota
  • 299
  • 5
  • 25

3 Answers3

1

view.requestFocus() is not enough;

I'm using this code:

public static void setSoftwareKeyboardVisibility(Context context, View view, boolean value) {
        final InputMethodManager manager = (InputMethodManager) context.getSystemService(Service.INPUT_METHOD_SERVICE);
        if (value) {
            view.requestFocus();
            manager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
        } else {
            // Any other not EditText View
            manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
            view.requestFocus();
        }
    }

But You said that standatr method is not working. Try to call showSoftInput not in OnFocusChange method. Call it when you setting focus on EditText.

nfirex
  • 1,523
  • 18
  • 24
  • Thank you for your reply, but still the focus is there on editText but the keyboard shows only after I touch the control :( – Adnan Pirota Nov 03 '13 at 11:17
  • @AdnanPirota , hmmmm. Do you change `windowSoftInputMode` for your activity in manifest? And what is value? – nfirex Nov 03 '13 at 12:17
0

I can not find now the page where I got resolution to my problem, but the solution was as follows:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Adnan Pirota
  • 299
  • 5
  • 25
0

With editText.requestFocus() where editText is your EditText View you focus the cursor to the field.

If you want to show the keyboard after focusing, look at the answer of raukodraug here.

Community
  • 1
  • 1
malliaridis
  • 389
  • 1
  • 12