小编And*_*ner的帖子

选择android中listview的所有复选框

我有用于列表视图,其内部包括复选框5次定制arrayadapter,在这里,我要实现的选择列表视图中所有的复选框,并取消所有复选框,我试着用getchildat()的方法oncreate(),onresume()以及onpostcreate同时,但不做出运气给我.如果你能告诉我解决方案,我很感激.

@Override
      public void onPostCreate(Bundle savedInstanceState){
          super.onPostCreate(savedInstanceState);

      Button selectall=(Button) findViewById(R.id.allselect);

      selectall.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            int count = listview.getCount();

            System.out.println("the count is "+count);
            for (int i = 0; i < listview.getLastVisiblePosition() - listview.getFirstVisiblePosition(); i++)  {

                RelativeLayout itemLayout = (RelativeLayout)listview.getChildAt(i);
                CheckBox cb = (CheckBox)itemLayout.findViewById(R.id.chkbx);
                cb.setChecked(true);

            }

        }
    });
  }
Run Code Online (Sandbox Code Playgroud)

Arrayadapter类

@SuppressWarnings("unchecked")
    public MultipleLeadSyncAdapter(Context context, String[] values,String[] values1,List<Model> qrcode ,String[] values3,String[] values4,String[] values5) {
        super(context, R.layout.multipleselectlist, values1);
        this.context = context; …
Run Code Online (Sandbox Code Playgroud)

checkbox android android-arrayadapter

1
推荐指数
1
解决办法
4687
查看次数

标签 统计

android ×1

android-arrayadapter ×1

checkbox ×1