在适配器中调用的片段中的按钮

Button in fragment called in adapter

我是新手 android 开发人员,我有一个包含两个复选框和一个按钮的列表。按钮在列表 class 中,复选框在适配器 class 中。当所有的复选框都被选中时,我必须做一个片段事务,这是按钮出现的时候。有一种方法可以从适配器中的片段调用按钮吗? 如果有人能告诉我,我将不胜感激

public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.ijueces_list_rondas, null);

            holder = new ViewHolder();
            holder.olblTable = (TextView) convertView.findViewById(R.id.lblTable);
            holder.olblWhite = (TextView) convertView.findViewById(R.id.lblWhite);
            holder.olblBlack = (TextView) convertView.findViewById(R.id.lblBlack);
            holder.ocheckBox1 = (CheckBox) convertView.findViewById(R.id.checkBox1);
            holder.ocheckBox2 = (CheckBox) convertView.findViewById(R.id.checkBox2);
            final CheckBox ocheckBox1 = (CheckBox) convertView.findViewById(R.id.checkBox1);
            final CheckBox ocheckBox2 = (CheckBox) convertView.findViewById(R.id.checkBox2);

            holder.ocheckBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() 
            {

                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
                {
                    if(isChecked){
                        counter=0;
                        if(ocheckBox2.isChecked()==true){
                            counter=0;
                        }
                        else{

                        }
                    }
                    else{
                        counter--;
                    }   
                }
            });

            holder.ocheckBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() 
            {
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
                {
                    if(isChecked){
                        counter++;
                        if(ocheckBox1.isChecked()==true){

                        }
                    }
                    else{

                    }   
                }
            });

抱歉版本问题,我使用的是小型设备,它不允许我编辑代码(那是我的适配器 class)

在您的适配器中创建一个方法 class 来 return 检查项目的数量。然后从你的 activity 调用它,比如

int count = adapter.getCheckedCount();

如果它们都被选中(计数等于您的列表大小),则继续进行 Web 服务调用。

here我也做了同样的事情..你可以得到一些想法。