当edittext为空并按添加按钮时,我的代码崩溃...我尝试将整数从edittext复制到数组...我该如何解决这个错误?我已经设置了edittext
android:inputType="numberDecimal"
我可以尝试...抓住吗?
public static ArrayList<Integer> pulseslist = new ArrayList<Integer>();
public int pulses1[]=null;
private OnClickListener btnAddListener = new OnClickListener() {
public void onClick(View v) {
String ag=editIRpulse1.getText().toString().trim();
if (ag!=null){
int intag= Integer.parseInt(ag);
if(ag.length() > 0){
pulseslist.add(intag);
editIRpulse1.setText(""); // adds text to arraylist and make edittext blank again
}
pulses1 = new int[pulseslist.size()];
for (int i = 0; i < pulseslist.size(); i++) {
pulses1[i] = pulseslist.get(i);
}
}
}
};