android EditText 去掉焦点和关闭软键盘
2012-07-04 15:34
274 查看
关闭软键盘 private void hideInputSoft() {
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
private void hideInputSoft() {
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
} private void hideInputSoft() {
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
mDigits.setInputType(android.text.InputType.TYPE_NULL);//关闭软键盘
android:focusable="true"
android:focusableInTouchMode="true"//这个两个属性决定了编辑框的焦点去掉
<LinearLayout
android:id="@+id/contacts_input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="invisible"
android:background="@drawable/dialbk"
android:focusable="true"
android:focusableInTouchMode="true"
>
<ImageButton
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/btn_dial_save_xml"
android:contentDescription="@string/description_delete_button"
android:state_enabled="false"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
/>
<EditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_weight="1"
android:background="@drawable/dial_input_text_bg_xml"
android:contentDescription="@string/description_digits_edittext"
android:drawableLeft="@drawable/ic_calllog_call_active"
android:minWidth="140.0dip"
android:paddingLeft="13.0dip"
android:paddingRight="4.0dip"
android:scrollHorizontally="true"
android:drawablePadding="7dip"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="22sp"
/>
<!-- </LinearLayout> -->
<ImageView
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/btn_dial_delete_xml"
android:contentDescription="@string/description_delete_button"
android:scaleType="centerCrop"
android:state_enabled="false"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"/>
</LinearLayout>
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
private void hideInputSoft() {
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
} private void hideInputSoft() {
try {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
mDigits.setInputType(android.text.InputType.TYPE_NULL);//关闭软键盘
android:focusable="true"
android:focusableInTouchMode="true"//这个两个属性决定了编辑框的焦点去掉
<LinearLayout
android:id="@+id/contacts_input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="invisible"
android:background="@drawable/dialbk"
android:focusable="true"
android:focusableInTouchMode="true"
>
<ImageButton
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/btn_dial_save_xml"
android:contentDescription="@string/description_delete_button"
android:state_enabled="false"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
/>
<EditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:layout_weight="1"
android:background="@drawable/dial_input_text_bg_xml"
android:contentDescription="@string/description_digits_edittext"
android:drawableLeft="@drawable/ic_calllog_call_active"
android:minWidth="140.0dip"
android:paddingLeft="13.0dip"
android:paddingRight="4.0dip"
android:scrollHorizontally="true"
android:drawablePadding="7dip"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="22sp"
/>
<!-- </LinearLayout> -->
<ImageView
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/btn_dial_delete_xml"
android:contentDescription="@string/description_delete_button"
android:scaleType="centerCrop"
android:state_enabled="false"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"/>
</LinearLayout>
相关文章推荐
- Android 设置Edittext获取焦点并弹出软键盘
- android EditText 自动获取焦点并弹出软键盘
- Android 中使 EditText 失去焦点,禁止弹出软键盘,及 弹出软键盘后 EditText 自动上移 不致被遮挡
- 关于android edittext 软键盘关闭问题
- android EditText自动弹出和自动关闭软键盘
- Android:ListView中包含EditText 文字冲突 复用 焦点 软键盘问题
- Android 点击listView的item弹出软键盘并且EditText获取焦点
- android中去掉EditText的自动焦点获取
- Android 当EditextText失去焦点,或者点击Activity的时候关闭软键盘或者其他布局
- Android EditText 软键盘和焦点问题
- android中动态给EditText获得焦点并弹起软键盘的方法详解
- Android EditText设置默认不弹出软键盘,点击EditText外部隐藏软键盘,EditText获取焦点时隐藏hint
- Android 如何让EditText不自动获取焦点 在项目中,一进入一个页面, EditText默认就会自动获取焦点。 那么如何取消这个默认行为呢? 在网上找了好久,有点 监听软键盘事件
- android 自动弹出软键盘,EditText自动获取焦点
- EditText获得焦点后,如何关闭软键盘
- 【android】禁止Edittext弹出软键盘并且使光标正常显示
- android获得焦点后隐藏软键盘
- android 代码开启和关闭软键盘
- Android EditText与软键盘的一些效果
- Android常用工具方法(关闭软键盘,安装apk,检测程序是否安装...)