将RadioButton从Java生成的ListView添加到RadioGroup

时间:2013-09-22 01:44:09

标签: java android listview

如何将listview按钮中的广播添加到radioGroup?

这是OnItemClick

的代码
  lvSearchResult.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                    long id) {
                final HashMap<String, String> item =  (HashMap<String, String>) parent.getItemAtPosition(position);
                final RadioButton rbAddITem = (RadioButton)parent.getChildAt(position).findViewById(R.id.rbAddItem_Radio);      
                String searchQuery = item.get("ProductName").toString();
                if(rbAddITem.isChecked()){
                    rbAddITem.setChecked(false);
                }else{
                    rbAddITem.setChecked(true);
                }   
            }
        });

    }

非常感谢你的帮助。

0 个答案:

没有答案