Sunday 15 May 2011

android - My textchanged listener is launching a loop when i hit the first row of my listview? -


I have a list view with 2 buttons, 1 textview and an editor, TextView in name of these products, two buttons ( - & amp; +) Amount to increase or decrease in my adtext.

Everything is working fine for 3 final lines (out of 4), it shows me in my list, product name, quantity, price, everything that I want but as soon as I I hit any button from the first line, she is going for 9 lap loops .. My toast is showing a new situation in each toast, leaving one in the first line except the quantity with the appropriate amount.

Here is the getView of my custom adapter which extends the BaseAdapter:

  @ override public view getView (see the status of int, seeviewview, ViewGroup parent) {if (convertView == faucet) {convertView = inflater.inflate (R.Layout.one_product, blank); } Final integer position = position; Button btnProdChoiMinus = (button) convertView.findViewById (RID.btnproductContinued); TextView tvProduit = (TextView) ConvertV.IDProduct; Button btnProdChoiPlus = (button) convertView.findViewById (R.id.btnProdChoiPlus); Last edit text and code = (Editing Text) ConvertviewfwdBiID (RN.Netquatite); Final product p = data.jet (status); BtnProdChoiMinus.setText (. ConvertView.getResources () GetString (R.string.lblMinus)); TvProduit.setText (p.getNom ()); BtnProdChoiPlus.setText (. ConvertView.getResources () GetString (R.string.lblPlus));   

See the same method I own 2 button listerners:

  btnProdChoiMinus.setOnClickListener (New OnClickListener () {@Override public void onClick (v) (..! EtQuantity.getText () toString () Length () = 0) (. EtQuantity.getText () toString ()) {if {quantite = Integer.parseInt - 1, if (quantite> 0) {etQuantity . setText ( "" + quantite);} else {etQuantity.setText ( "");}} else {Toast.makeText (reference, R.string.lblErrQuantity_fr, Toast.LENGTH_SHORT) .show ();}}}); btnProdChoiPlus.setOnClickListener (New OnClickListener () {@Override see public void onClick (v) {if (etQuantity.getText (). toString (). length ()! = 0) {quantite = Integer.parseInt (etQuantity.getText () .toString ()) + 1; Atquity.Set Text ("" + volume);} and {atquity.set text ("1");}}});   

And yet in the same method, my text-linked lister is causing this problem:

  at cotiette.extext changelistener (new textvotter () {@ override public onTextChanged (CharSequence s, int start, before int, int count) {} @Override public void beforeTextChanged (CharSequence s, int start, since the integer count, int) {// TODO auto-generated method Stub} @Override Public Zero afterTextChanged (Edit Not suitable) {ifQuantity.getText () toString () Length () = 0 ..!) {Quantite = Integer.parseInt (etQuantity.getText () toString ().); Toast.makeText (Reference, "Position : "+ Pos +" product: "+ p.getNom () +" id: "+ p.getId () +" Prix: "+ p.getPrix () +" Kwantiae: + quantitative, toast. Elananjiacaiacoaraarti). Show (); // ((new order activity)). Update Ordered Products (PGIID), P.Jenet (), P.JetProx (), quantitative);}}}; Return Convertview;}   

I already switch from Test switch to on-test switch Has tried but it does not help.

Your help is highly appreciated;)

Regards,

Apple

This is because etQuantity.addTextChangedListener each time add another listener to your atquality widget.

Then when you look in ListView , you can just add another listener to atquality (not replace the old one) again. : Are using, and it will fire all the listeners. For example, try to use and the amount Attkwatiti loose focus (you do ((New Oderaktiviti) activity should add) .updateOrderedProducts (p.getId (), p.getNom ( ), GetPrix (), quantitative) instead of etQuantity.addTextChangedListener onClick listener of your buttons) listener in the holder And only once, when you make the holder call etQuantity.addTextChangedListener

No comments:

Post a Comment