【Android 界面技巧】输入框不聚焦,以及首次点击清空输入框
来源:互联网 发布:云计算行业发展趋势 编辑:程序博客网 时间:2024/05/17 22:17
1.进入界面输入框不聚焦
让EditText控件的的父控件拦截聚焦事件就好了,具体代码如下。
核心代码就是 :
android:focusable=”true”
android:focusableInTouchMode=”true”
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="true" android:focusableInTouchMode="true" android:orientation="horizontal"> <EditText android:id="@+id/editWifiPwd" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/wdp22" android:layout_marginRight="@dimen/wdp22" android:layout_marginTop="@dimen/wdp58" android:background="@drawable/gw_wifi_inputbox_bg" android:digits=" !"#$%&'()*+,-./:;>=<?@[]^`{_|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\" android:drawablePadding="@dimen/wdp28" android:hint="@string/gw_wifi_pwd_hint" android:inputType="textPassword" android:maxEms="128" android:maxLength="128" android:padding="@dimen/wdp10" android:paddingLeft="@dimen/wdp28" android:paddingRight="@dimen/wdp18" android:singleLine="true" android:textColor="@color/gw_text_gray" android:textColorHint="@color/gw_hint_color" android:textSize="@dimen/wdp28" />
2.首次点击清空输入框
setOnFocusChangeListener 是一个输入框的聚焦监听事件操作,在监测到聚焦后清空输入框即可。
例子如下:
private boolean isFirst = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); isFirst = true; mWifiPwd.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { EditText editText = (EditText) view; if (isFirst && hasFocus) { isFirst = false; editText.setText(""); } } }); }
0 0
- 【Android 界面技巧】输入框不聚焦,以及首次点击清空输入框
- Android 清空输入框内容
- Android中控制点击EditText输入框右边清空图标的显示与隐藏.
- 清空页面输入框中值
- jquery清空textarea等输入框
- file输入框无法清空
- Angular4_清空input输入框
- element清空单个输入框
- iOS判断输入框不为空格以及空
- 输入框聚焦,点击时清空文本框_表单按钮特效
- 输入框点击内容清空或显示的js代码
- 【jQuery】简单的点击删除按钮清空输入框的内容
- 清空输入流
- 输入框只能输入数字,否则自动清空||只能输入英文和数字
- 输入框显示输入提示,点击消失。没输入直接提交,提交的输入框内容为空,不提交显示的提示文字
- android webview 输入框点击不弹键盘
- 点击输入框显示一个时间选择界面
- 点击输入框显示一个时间选择界面
- eclipse最有用快捷键整理
- No tests found matching 【junit 异常】
- Jpush使用总结 _ 客户端定义通知栏样式
- 你不要太天真,招聘广告到底能信几成?
- 从PHP语法糖剖析Zend VM引擎
- 【Android 界面技巧】输入框不聚焦,以及首次点击清空输入框
- SpringMvc自定义拦截器
- 【Web】Jsp基础学习
- 全排列问题
- C# webservices 天气预报 VS2015版本
- Oracle数据库基本常用命令
- 【项目1 - 二叉树算法库】
- angularJS ng-repeat
- MySQL存储过程详解