edittext专注于在android中可见

时间:2014-03-20 05:34:26

标签: android android-edittext visibility

我有一个edittext.It是不可见的defalut.On点击列表项它是可见的。我想focust编辑文本,当它是可见的。并打开软键盘。我有很多搜索,但它没有工作可见而且看不见。 代码:

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 个答案:

答案 0 :(得分:2)

尝试使用

edit_other.requestFocus();

答案 1 :(得分:1)

你可以尝试一下,看看:

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

希望它有所帮助!