yamuna
yamuna

Reputation: 41

unable to set the edittext value to textview based on position

I have an edit text in list view. Every time the edit text value from listview is updating into database. I have the recipe quantity(which is edit text value) and recipe price also in db. I am getting those prices and saves in setprice variable. but now i am trying to set those values into text view as per listview position. But i am able to set the multipled value to proper position it sets as it wishes

     quantityt.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start,
                int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start,
                int before, int count) {
            valueList[position] = s.toString();
            Log.e("", "-----value list of position----"
                    + valueList[position]);
            quantityval = valueList[position];
            Log.e("", "quantityval-----" + quantityval);
            int selectedid = getid.get(position);
            Log.e("", "selectedid-----" + selectedid);
            te=db.update(quantityval, selectedid);
            Log.e("", "te----" + te);
            int getprice = pricesarray.get(position);
            setprice = getprice * te;
            Log.e("", "---set price value---" + setprice);
            int id = (int) list.getItemIdAtPosition(position);
             lContact.setExt(setprice);

            // Log.e("", "lcontact.getExt value---"+lContact.getExt());
            holder.setprice.setText(String.valueOf(setprice));



        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

Upvotes: 1

Views: 265

Answers (1)

Pratik Dasa
Pratik Dasa

Reputation: 7439

Try with below code:

quantityt.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start,
                int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start,
                int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
valueList[position] = s.toString();
            Log.e("", "-----value list of position----"
                    + valueList[position]);
            quantityval = valueList[position];
            Log.e("", "quantityval-----" + quantityval);
            int selectedid = getid.get(position);
            Log.e("", "selectedid-----" + selectedid);
            te=db.update(quantityval, selectedid);
            Log.e("", "te----" + te);
            int getprice = pricesarray.get(position);
            setprice = getprice * te;
            Log.e("", "---set price value---" + setprice);
            int id = (int) list.getItemIdAtPosition(position);
             lContact.setExt(setprice);

            // Log.e("", "lcontact.getExt value---"+lContact.getExt());
            holder.setprice.setText(String.valueOf(setprice));
        }
    });

Upvotes: 1

Related Questions