Question

I have one edittext.It is INVISIBLE by defalut.On click of list item it is visible.I want to focust edit text when it is visible.and opens soft keyboard.i have searches alot but it is no working on visible and Invisible. CODE:

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            list_selection=((TextView)arg1).getText().toString();
            if(list_selection.equals("Other"))
            {

                edit_other.setVisibility(View.VISIBLE);
                edit_other.setFocusable(true);
                edit_other.setCursorVisible(true);
                other.setVisibility(View.VISIBLE);
                image.setVisibility(View.VISIBLE);


                ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

            }
Was it helpful?

Solution 2

You could give this a try and see :

 if(edit_other.requestFocus()) {
     getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 }

Hope it helps !

OTHER TIPS

try to use

edit_other.requestFocus();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top