在EditText 过滤Filtering 数据
来源:互联网 发布:远程重启linux 编辑:程序博客网 时间:2024/05/24 06:33
注:(标题有改动)原文出自:http://wang-peng1.javaeye.com/blog/669520 和 http://wang-peng1.javaeye.com/blog/669384
一 。edit不可编辑的实现
import android.app.Activity;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
/**
* Class which shows how to lock and unlock EditText component
*
* @author FaYnaSoft Labs
*/
public class Main extends Activity {
private EditText editText;
private boolean value = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
editText = (EditText) findViewById(R.id.textId);
editText.setText(“EditText component”);
Button b = (Button) findViewById(R.id.btnId);
b.setText(“Lock/Unlock”);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (value) {
value = false;
} else {
value = true;
}
lockUnlock(value);
}
});
}
/**
* Method which locks and unlocks editText component
* @param value our boolean value which using in or if operator
*/
private void lockUnlock(boolean value) {
if (value) {
editText.setFilters(new InputFilter[] { new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
return source.length() < 1 ? dest.subSequence(dstart, dend)
: “”;
}
} });
} else {
editText.setFilters(new InputFilter[] { new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
return null;
}
} });
}
}
}
二 。 在edittext中过滤Filtering,可用的数据
emailText.setKeyListener(new NumberKeyListener() {
@Override
public int getInputType() {
return InputType.TYPE_MASK_VARIATION;
}
@Override
protected char[] getAcceptedChars() {
return new char[]{‘i’, ‘o’, ‘p’, ‘a’, ‘s’, ‘d’, ‘f’, ‘g’,
‘h’, ‘j’, ‘k’, ‘l’, ‘z’, ‘x’, ‘q’, ‘w’, ‘e’, ‘r’, ‘t’,
‘y’, ‘u’, ‘c’, ‘v’, ‘b’, ‘n’, ‘m’, ‘.’, ‘@’, ‘_’, ’1′, ’2′,
’3′, ’4′, ’5′, ’6′, ’7′, ’8′, ’9′, ’0′,};
}
});
——————————————————————————-
emailText.setKeyListener(new NumberKeyListener() {
@Override
public int getInputType() {
return InputType.TYPE_NULL;
}
@Override
protected char[] getAcceptedChars() {
return new char[]{‘i’, ‘o’, ‘p’, ‘a’, ‘s’, ‘d’, ‘f’, ‘g’,
‘h’, ‘j’, ‘k’, ‘l’, ‘z’, ‘x’, ‘q’, ‘w’, ‘e’, ‘r’, ‘t’,
‘y’, ‘u’, ‘c’, ‘v’, ‘b’, ‘n’, ‘m’, ‘.’, ‘@’, ‘_’, ’1′, ’2′,
’3′, ’4′, ’5′, ’6′, ’7′, ’8′, ’9′, ’0′,};
}
});
………………………………………………………………………….
emailText.setText(“EditText element”);
emailText.setKeyListener(new NumberKeyListener() {
@Override
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
return source.length() < 1 ? dest.subSequence(dstart, dend) : “”;
}
@Override
public int getInputType() {
return InputType.TYPE_MASK_VARIATION;
}
@Override
protected char[] getAcceptedChars() {
return new char[]{‘i’, ‘o’, ‘p’, ‘a’, ‘s’, ‘d’, ‘f’, ‘g’,
‘h’, ‘j’, ‘k’, ‘l’, ‘z’, ‘x’, ‘q’, ‘w’, ‘e’, ‘r’, ‘t’,
‘y’, ‘u’, ‘c’, ‘v’, ‘b’, ‘n’, ‘m’, ‘.’, ‘@’, ‘_’, ’1′, ’2′,
’3′, ’4′, ’5′, ’6′, ’7′, ’8′, ’9′, ’0′,};
}
});
- 在EditText 过滤Filtering 数据
- 数据挖据-协同过滤算法 (collaborative-filtering, CF)
- django tastypie filtering 数据过滤(条件查询)
- 过滤软件 filtering software
- 消息过滤(Message Filtering)
- Filtering 过滤操作
- Collaborative filtering 协同过滤
- 协同过滤Collaborative Filtering
- 入过滤(Ingress Filtering)
- collaborative filtering (CF):协同过滤
- collaborative filtering (CF):协同过滤
- EditText结合过滤器Fileter实现数据过滤效果的设计
- Hibernate中的过滤集合类Filtering collections
- 14.64.1 表格行过滤 JTable Filtering
- Collaborative filtering 协同过滤算法 Slope One
- 协同过滤(英语:Collaborative Filtering)
- RailsCasts9 Filtering Sensitive Logs 过滤敏感日志
- Collaborative Filtering协同过滤推荐算法
- Using EzSetup for creating Pocket PC installations
- 解读iPhone平台的一些优秀设计思路
- fedora13下安装quartus 10.0sp1与niosII 10.0sp1
- 使用Android自带Gallery组件实现CoverFlow,源码+解析
- SVN+Apache+AnkhSVN(或者VISUALSVN)搭建版本控制环境
- 在EditText 过滤Filtering 数据
- 重写页面中form中的action(隐藏页面地址)
- Visual Studio 2008小助手安装
- Can someone explain what Business Units, TableSets and SetIDs are
- TCP/IP 详解 卷1 ch17 TCP: Transmission Control Protocol
- Struts2输出数组或List
- shell学习笔记
- 一 Cocoa编程学习心得
- 重置 Ubuntu 的 Gnome 桌面的设置