开发者

Android list view not mapping correctly

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


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

       ll = vi.inflate(R.layout.contact_list_row, null);


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);
    }

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜