final EditTextNoKeyBoard eText = new EditTextNoKeyBoard(context);
eText.setBackgroundResource(R.drawable.edit_text_border);
eText.setTextColor(context.getResources().getColor(R.color.appInputTextColor));
// eText.setGravity(Gravity.CENTER_HORIZONTAL);
// eText.setFocusableInTouchMode(true);
eText.setRawInputType(InputType.TYPE_CLASS_TEXT);
eText.setInputType(0);
eText.setTextIsSelectable(true);
eText.setWidth(100);
eText.setSingleLine();
EditTextNoKeyBoard类是
public class EditTextNoKeyBoard extends EditText
{
public EditTextNoKeyBoard(Context context)
{
super(context);
}
public EditTextNoKeyBoard(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
public EditTextNoKeyBoard(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@Override
public boolean onCheckIsTextEditor()
{
return true;
}
}
答案 0 :(得分:0)
在编辑文本时,焦点隐藏系统键盘
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}