質問

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);

            }
役に立ちましたか?

解決 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 !

他のヒント

try to use

edit_other.requestFocus();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top