vendredi 30 juin 2017

custom listview checkbox and edit box loss data when scroll down

hello every one i am new to android i have custom Listview with edittext and check box when i check the box and enter data in edittext and scroll the listview and return back to that box its change its state to previous state means unchecked and edittext box data lost public

View getView(final int position, View arg1, ViewGroup viewGroup) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.stocklistcustom, viewGroup, false);
        final CheckBox checkbox1 = (CheckBox) row.findViewById(R.id.checkbox1);
        TextView Des = (TextView) row.findViewById(R.id.description);
        final TextView stockid = (TextView) row.findViewById(R.id.stockid);
        final EditText done = (EditText) row.findViewById(R.id.quantity);

        stockid.setText(listItem.get(position));
        Des.setText(listAddress.get(position));
        done.setText(quantity.get(position));

        checkbox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                int i=0;
                if (checkbox1.isChecked()){

                    String id,qu,des,stc;
                    id=idlist.get(position);
                    qu=quantity.get(position);
                    des=listAddress.get(position);
                    stc=listItem.get(position);

                    ItemID_list.add(i,id);
                    StockCode_list.add(i,stc);
                    Description_list.add(des);
                    Quantity_list.add(i,done.getText().toString());



                }

                else {

                    ItemID_list.remove(i);
                    StockCode_list.remove(i);
                    Description_list.remove(i);
                    Quantity_list.remove(i);
                    i--;
                }
            }
        });

        //date.setText(dates);



        return row;
    }

this is my getview function if any body can solve this problem please




Aucun commentaire:

Enregistrer un commentaire