我有多個動態edittext。我想更改下一個edittext的值,以更改以前的edittext的值。但我的代碼給了StackOverflow異常。請幫忙。Stackoverflow在Android中動態Edittext中發佈文本時發生異常
代碼:
edt_pay_option.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
sum = 0.0;
last = allEds.get(allEds.size()-1);
for (int j = 0; j < allSign.size(); j++) {
sign[j] = allSign.get(j).getText().toString();
}
for (int i = 0; i < allEds.size(); i++) {
amount[i] = allEds.get(i).getText().toString();
if (!allEds.get(i).getText().toString().equals("")) {
if (allEds.get(i).getText().toString().equals(".")) {
allEds.get(i).setText("0.");
}
if (sign[i] == "-") {
value = Double.parseDouble("-"
+ allEds.get(i).getText().toString());
} else {
value = Double.parseDouble(""
+ allEds.get(i).getText().toString());
}
} else {
value = 0.0;
}
List<Double> value1 = new ArrayList<Double>();
value1.add(value);
for (int j = 0; j < value1.size(); j++) {
sum = sum + value1.get(j);
}
paidAmount = Double.parseDouble(new DecimalFormat("0.00")
.format(sum));
outstandingAmount = totalAmount - paidAmount;
try {
if(allEds.size()>1){
last.setText(Double.toString(outstandingAmount));
;
}
} catch (StackOverflowError e) {
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
}
});
刪除xml文件中不需要的視圖和佈局 –
看看這篇文章:http://stackoverflow.com/questions/21749387/stackoverflow-erro-in-android –