【问题标题】:Can I get data from custom adapter with clicking on a check box inside the adapter's item?我可以通过单击适配器项目内的复选框从自定义适配器获取数据吗?
【发布时间】:2017-01-24 17:14:10
【问题描述】:

我不想点击适配器的项目(OnItemClickListener),我只想选中项目中的复选框,如果选中,则从该项目中获取数据。

【问题讨论】:

    标签: android android-studio checkbox android-adapter


    【解决方案1】:

    ListView 中有复选框吗? ListView 中的 İf 复选框,您可以使用以下代码:

    @Override    
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        CheckBox checkB=(CheckBox) v.findViewById(R.id.your_checkbox_id);
        if(checkB.isChecked()){
          //you can get data from here
          //for example: checkB.getText();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-08-25
      • 1970-01-01
      • 2016-01-12
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      • 2013-09-02
      • 1970-01-01
      • 2015-05-26
      相关资源
      最近更新 更多