我正在使用Android Studio w/java,我正在编程一个按钮来重置我的数字文本框的值:
et1.setText(""); //clear the first numeric text box value
et2.setText(""); //clear the second numeric text box value
tv1.setText(""); //clear the third numeric text box value
?????????????; //here I need to select et1 (the first numeric textbox)
问题是……清除值后如何选择et1 ?
你可以把你的EditText与et1.requestFocus()
,然后打开你的键盘:
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}