views:

26

answers:

3

Hello .................... i have a list view and custom list adapter for it. There are various other fields in it and a Checkbox. The problem is that it is not able to map Checkboxes properly. I mean if an entry is already present in database it should come checked.

When i put a log in the View function it shows some of the entries that are repeated, i think this is the main reason.

I need some help badly.

Thanks

A: 

here is the code:

public View getView(int position, View convertView, ViewGroup parent) { LinearLayout ll; LayoutInflater vi;

    if (convertView == null)
    {

       ll=new LinearLayout(this._c);    
       String inflater = Context.LAYOUT_INFLATER_SERVICE;

       vi = (LayoutInflater)this._c.getSystemService(inflater);
       vi.inflate(R.layout.contact_list_row, ll, true);

    }
    else
    {
        ll = (LinearLayout)convertView;
    }

    TextView tv =(TextView)ll.findViewById(R.id.name);
    tv.setText(ml.getString1());

    tv =(TextView)ll.findViewById(R.id.phoneNo);
    tv.setText(ml.getString2());

    CheckBox check=(CheckBox)ll.findViewById(R.id.check);

    final numberDatabase nd=new numberDatabase(ml.getContext());
    nd.setListType(ml.getIntegerValue1());

    Log.i("number exists",ml.getString1());

    if(nd.numberExists(ml.getString2()))
    {
        //Log.i("number exists",ml.getString2());
        //check.setChecked(true);
    }
    else
    {
        //Log.i("number not exists",ml.getString2());
        //check.setChecked(false);
    }

}

viv
Any help ?????????????
viv
Next time please edit your question and put the code there! Not as an answer.
Sameer Segal
kkkkkkki will keep in mindThanks
viv
sorry problem not resolved it's still checking and unchecking wrong values..........it's causing problem only while scrolling...........
viv
A: 

If you include this line it should work and uncomment the if-block:

       ll = vi.inflate(R.layout.contact_list_row, null);
Sameer Segal
A: 

Got it working, instead of invoking oncheckchangelistener from inside getView i did it from onListItemClick.............. Now it's working fine..

Thanks everyone.....

viv