below is my textwatcher class I am trying to change the textview content of my list based on the changes from the edittext of the list.
public class MtQtyWatcher implements TextWatcher {
View v;
public MtQtyWatcher(View v){
this.v = v;
}
public void afterTextChanged(Editable s) {
String qty = s.toString().trim();
int quantity = qty.equals("")?0:Integer.parseInt(qty);
EditText edtQty = (EditText)v.findViewById(R.id.qty);
Item item = (Item)edtQty.getTag();
if(item.getQty()!=quantity){
edtQty.setText(qty);
item.setQty(quantity);
float newRate = quantity * (item.getRate());
item.setAmt(newRate);
TextView txtAmt = (TextView) v.findViewById(R.id.amt);
txtAmt.setText(""+item.getAmt());
}
}
public void beforeTextChanged(CharSequence s, int start, int count,int after) {}
public void onTextChanged(CharSequence s, int start, int before,int count) {}
}
This is the following stacktrace
04-10 15:00:13.179: E/AndroidRuntime(24454): FATAL EXCEPTION: main
04-10 15:00:13.179: E/AndroidRuntime(24454): java.lang.StackOverflowError
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.SpannableStringBuilder.getSpans(SpannableStringBuilder.java:783)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.method.ReplacementTransformationMethod$SpannedReplacementCharSequence.getSpans(ReplacementTransformationMethod.java:184)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Styled.drawUniformRun(Styled.java:67)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Styled.drawDirectionalRun(Styled.java:322)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Styled.measureText(Styled.java:454)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.measureText(Layout.java:1971)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.getLineMax(Layout.java:912)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.getLineMax(Layout.java:886)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.getHorizontal(Layout.java:742)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.getHorizontal(Layout.java:703)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.text.Layout.getPrimaryHorizontal(Layout.java:688)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.getFocusedRect(TextView.java:4522)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.FocusFinder.findNextFocus(FocusFinder.java:72)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:476)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.View.focusSearch(View.java:3494)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.onCreateInputConnection(TextView.java:4922)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:945)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:900)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2734)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): at com.eshopping.u.ItemList$MtQtyWatcher.afterTextChanged(ItemList.java:144)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.sendAfterTextChanged(TextView.java:6724)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2822)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2676)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.EditText.setText(EditText.java:178)
04-10 15:00:13.179: E/AndroidRuntime(24454): at android.widget.TextView.setText(TextView.java:2651)
04-10 15:00:13.179: E/AndroidRuntime(24454): a