Android 编辑文本焦点问题
我有一个活动,在一个活动中,编辑文本有一些提示文本 默认情况下,当我启动活动时,重点放在编辑文本和不可见提示上 请告诉我如何使提示可见Android 编辑文本焦点问题,android,android-edittext,focus,Android,Android Edittext,Focus,我有一个活动,在一个活动中,编辑文本有一些提示文本 默认情况下,当我启动活动时,重点放在编辑文本和不可见提示上 请告诉我如何使提示可见 谢谢在页面中添加一个空视图: <LinearLayout android:focusable="true" android:focusableInTouchMode="true" android:layout_width = "0dp" android:layout_height = "0dp"/> 此视图将获得焦点,并防止E
谢谢在页面中添加一个空视图:
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width = "0dp"
android:layout_height = "0dp"/>
此视图将获得焦点,并防止
EditText
获取它在页面中添加一个空视图:
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width = "0dp"
android:layout_height = "0dp"/>
此视图将在setContentView()之后获得焦点,并阻止EditText
获取它:
设置输入法:
private void setInput(EditText _editText, KeyListener keyListener, InputMethodManager imm){
_editText.setKeyListener(keyListener);
if (_editText.isFocusable()) {
_editText.setFocusable(true);
_editText.setFocusableInTouchMode(true);
_editText.requestFocus();
}
_editText.setSelection(_editText.getText().length());
imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(_editText, InputMethodManager.SHOW_IMPLICIT);
}
在setContentView()之后:
设置输入法:
private void setInput(EditText _editText, KeyListener keyListener, InputMethodManager imm){
_editText.setKeyListener(keyListener);
if (_editText.isFocusable()) {
_editText.setFocusable(true);
_editText.setFocusableInTouchMode(true);
_editText.requestFocus();
}
_editText.setSelection(_editText.getText().length());
imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(_editText, InputMethodManager.SHOW_IMPLICIT);
}
在setContentView()之前的onCreate中添加此行
另外,如果xml部分中有requestFocus,则将其删除在setContentView()之前的onCreate中添加此行 另外,如果xml部分中有requestFocus,则将其删除