0
A
回答
2
请使用下面的代码。
public class Help extends Activity {
public static int count = 0;//use this to check is there are more that 4 '.' char
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((EditText)findViewById(R.id.EditText01)).addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
if(count>=4){
//don't allow to right text
}
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
//check here if entered text contains more than 4 '.' character
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
}
请检查我没有测试过
+0
thnx ..求助 – 2011-01-06 13:14:39
0
Edittext e = (editText)Findviewbyid.....
String t= e.geteditable().gettext(); // check methods
if(s.equals(".") || s.equals("..") || s.equals("...")
{
throw some exception and reset it in the catch block
}
我能理解你的问题。这是你想要的吗?
0
下面的脚本逻辑计算各个时期,但多个周期计算一次:...
= .
,并在一开始preriods不计算在内。
String text = ((EditText)findViewById(R.id.yourEditText)).getText().toString();
if(text.matches("\\.*[^\\.]+\\.+[^\\.]+\\.+[^\\.]+\\.+[^\\.]+\\.+.+")){
// 4 or more '.', multiple '..' are counted once
}
相关问题
- 1. 计算一个cron的运行时间
- 2. 计算特定字符的出现
- 3. 计算一个特定的字符串可以显示在一个uilabel中的字符数
- 4. 计算特定行
- 5. 设置一个计算属性的从属键在运行时
- 6. Ruby - 在运行时在变量中计算字符串占位符
- 7. 在SQL中计算特殊字符
- 8. 字符串运算(子串)在夫特
- 9. 在特定计算机上运行速度非常慢的JavaScript
- 10. 计算算法运行时?
- 11. 计数特定字符串的发生在一个文件
- 12. 计算在特定时间范围内运行的实例的数量
- 13. 在计算数组时计算运行时错误
- 14. 在MySQL中计算特定行
- 15. 如何计算记事本中所有行的特定字符++
- 16. 在运行时确定可用的运算符
- 17. 做一个字符串确定特定字符的存在
- 18. 如何识别一个特定发生在两个行和计算计数
- 19. 用户输入的字符串在c中运行一个特定的函数
- 20. 使用SubString计算字符串中的特定字符
- 21. Haskell计算包含字符串中特定字符的单词
- 22. 计算字符串内特定字符的数量
- 23. 计算字符串中特定字符的出现次数
- 24. 计算字符串中的特定字符数
- 25. 计算列验证接受一个特定的字符和数字只有
- 26. 在运行时计算百分比
- 27. 计算机在运行eclipse时关闭
- 28. 计算换行符每N个字符?
- 29. 如何在计算代码行时跳过特定的文件?
- 30. 计算固定长度文件中行数,第12个特定字符在每行中的位置
连续4次或总共4次?你已经有了一个可以读取其内容的`EditText`和`Activity`的布局吗? – 2011-01-06 10:57:51