문제

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