level 6
有个方法叫deleteSurroundingText..传个1,0…顺便API是个好东西
2017年02月26日 12点02分
8
level 7
boolean sFlag = false;
try{
EditText edt=(EditText)findViewById(R.id.edt);
String ss2=edt.getText().toString();
StringBuffer sb = new StringBuffer(ss2);
sb.deleteCharAt(ss2.length()-1);
ss2 =sb.toString();
edt.setText("");
int index = edt.getSelectionStart();//获取光标所在位置
edt.getText().insert(index,ss2);//光标所在位置插入文字
//需要捕获异常的代码
//新加的抛异常代码,但不在这里抛,这里是正常代码
if(edt==null){
sFlag = true;
}
}catch(Exception e){
System.out.print("空异常");Toast.makeText(getApplicationContext(), "!",
Toast.LENGTH_LONG).show();
}
if(sFlag){try
{throw new Exception();
}
catch (Exception e)
{Toast.makeText(getApplicationContext(), "!",
Toast.LENGTH_SHORT).show();
}
}
2017年03月07日 04点03分
10