edittext专注于android中的可视性
我有一个edittext。它是由defalut不可见的。单击列表项它是可见的。我想在它可见时聚焦编辑文本。并打开软键盘。我有很多搜索,但它不处理可见和不可见。 代码:edittext专注于android中的可视性,android,android-edittext,visibility,Android,Android Edittext,Visibility,我有一个edittext。它是由defalut不可见的。单击列表项它是可见的。我想在它可见时聚焦编辑文本。并打开软键盘。我有很多搜索,但它不处理可见和不可见。 代码: public void onItemClick(适配器视图arg0、视图arg1、内部arg2、, 长arg3){ list_selection=((TextView)arg1.getText().toString(); 如果(列表_选择等于(“其他”)) { 编辑_other.setVisibility(View.VISIBLE
public void onItemClick(适配器视图arg0、视图arg1、内部arg2、,
长arg3){
list_selection=((TextView)arg1.getText().toString();
如果(列表_选择等于(“其他”))
{
编辑_other.setVisibility(View.VISIBLE);
编辑_other.setFocusable(true);
编辑_other.setCursorVisible(true);
其他.setVisibility(View.VISIBLE);
image.setVisibility(View.VISIBLE);
((InputMethodManager)getSystemService(Context.INPUT\u METHOD\u SERVICE)).toggleSoftInput(InputMethodManager.SHOW\u强制,InputMethodManager.HIDE\u仅隐式);
}
尝试使用
edit_other.requestFocus();
您可以试试看:
if(edit_other.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
希望有帮助!谢谢你。我尝试了dis。((InputMethodManager)getSystemService(Context.INPUT\u METHOD\u SERVICE))。切换SoftInput(InputMethodManager.SHOW\u强制,InputMethodManager.HIDE\u仅限隐式);是的。如果条件存在,我将丢失。
if(edit_other.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}