TextWatcher的使用
来源:互联网 发布:ug编程侧铣头走圆弧 编辑:程序博客网 时间:2024/06/18 10:00
实现接口的三个方法
public void afterTextChanged(Editable s)
public void beforeTextChanged(CharSequence s, int start, int count, int after)
public void onTextChanged(CharSequence s, int start, int before, int count)
package com.example.androidtest;import android.os.Bundle;import android.app.Activity;import android.widget.EditText;import android.text.TextWatcher;import android.text.Editable;import java.text.NumberFormat;public class MainActivity extends Activity {EditText mText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mText = new EditText(this); setContentView(mText); } }class CurrencyTextWatcher implements TextWatcher{boolean mEditing;public CurrencyTextWatcher(){mEditing = false;}public synchronized void afterTextChanged(Editable s){if (!mEditing) {mEditing = true;String digits = s.toString().replace("\\D", "");NumberFormat nf = NumberFormat.getCurrencyInstance();try {String formmated = nf.format(Double.parseDouble(digits) / 100);s.replace(0, s.length(), formmated);} catch (NumberFormatException e) {s.clear();}mEditing = false;}}public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { }}
0 0
- TextWatcher的使用
- TextWatcher的使用
- OnEditorActionListener与TextWatcher 的使用
- Android中的TextWatcher的使用
- android的TextView的TextWatcher使用
- Android - TextWatcher监听事件的使用
- EditText实时监听TextWatcher的使用
- 使用TextWatcher监听EditText
- Android TextWatcher使用详解
- EditText焦点的获取和TextWatcher的使用
- 使用TextWatcher实现EditView的度分秒控制输入。
- TextWatcher接口在使用中碰到的问题
- TextWatcher接口的使用:监听EditText文字变动事件
- Android使用TextWatcher匹配email造成ANR的解决
- TextWatcher() 的用法
- TextWatcher的用法
- TextWatcher
- TextWatcher
- 九度题目1088:剩下的树
- C# 序列化与反序列化
- 解决Flex4 发布后访问 初始化极其缓慢的问题
- 抽象类和接口的区别与使用
- STL List::sort() 解析
- TextWatcher的使用
- u-boot-2009.08在2440上的移植详解(三)
- gcc基本用法
- VC6.0 操作Excel表格
- 第五周作业——有向图邻接表表示及反向图构造
- 网络爬虫C实现http://blog.csdn.net/xu3737284/article/details/9614933
- 有向图邻接表表示及反向图构造(第五周作业)
- u-boot-2009.08在2440上的移植详解(四)
- 移动开发学习地址