java事件关注EditText
我有一个EditText,其中EditText获得焦点,它会改变EditText的功能,当我失去EditText的焦点时,它会再次改变功能
这是我的源代码:
tambah = (EditText)rootView.findViewById(R.id.total);
tambah.setOnFocusChangeListener(new OnFocusChangeListener(){
@Override
public void onFocusChange(View arg0, boolean arg1) {
try {
if(..) //i want to check, i get focus
{...}else //if i loss focus, the textbox do something
{...}
} catch (Exception e) {
}
}
对于第一次单击edittext时的结果,edittext没有执行任何操作。当我输入“1000”并失去焦点时,edittext变为“1.000”。但当我再次单击edittext时,它又变为“1000”。请帮帮我,如果我的语法不好,请原谅
# 1 楼答案
布尔标志=真
编辑: 如果你需要一个简单的格式化程序,你可以使用十进制格式化程序