Android listview with checkbox problem

前端 未结 2 1295
清歌不尽
清歌不尽 2020-12-01 00:13

I have a weird problem! I\'m trying to create a listview with checkboxes. In my other thread I was told that I should use an array that keeps track of the rows that are chec

2条回答
  •  有刺的猬
    2020-12-01 00:59

    Check this for Single selection of Checkbox in Listview

    AdpList adapter=new AdpList(this,array,false);
    listview.setAdapter(adapter);
    

    When you select any Item then on item CLickListener do as Follows

    listview.setonItemClickListener(new OnItemClickListener)
    

    Here You will Get the Position of the Current Item

    array.get(Position);
    

    Get the Checkbox view and On clicking the Checkbox, create a method in Adapter, Like

    adapter.setList(true);
    adapter.notifyDataSetChanged();
    

    And In Adapter check the Parameter that I have Passed in the Setlist method then put condition:

    if (isChecking==true)
    {
    checkbox1.setChecked(true);
    }else{
    checkBox1.setChecked(false);
    }
    

提交回复
热议问题