xml中
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15<!--用户输入信息--> <EditText android:id="@+id/ed_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入文字信息" android:text="" android:inputType="text"/> <!--提示信息--> <TextView android:id="@+id/tip_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=""/>
Activity中
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25//在onCreate方法中: private EditText et_1; et_1 = (EditText)findViewById(R.id.ed_1); final TextView tip_1 = (TextView)findViewById(R.id.tip_1); et_1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // tip_1.setText("输入没改变"); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // tip_1.setText("输入正在改变"); } @Override public void afterTextChanged(Editable s) { // if(et_1.getText().toString().equals("123"))tip_1.setText("输入了123"); // if(et_1.getText().toString().equals("12"))tip_1.setText("输入了12"); } });
最后
以上就是动听咖啡最近收集整理的关于addTextChangedListener文本监听器的全部内容,更多相关addTextChangedListener文本监听器内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复