0
我有结构这样我怎样才能在一个列表视图按钮上点击所有选中的单选按钮
的TextView
收音机1第二广播电台
的TextView
收音机1第二广播电台
的TextView
收音机1 radio2
我想知道如何获取按钮上的所有选中的单选按钮 我想这样
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RadioGroup rgp;
RadioButton rbtn;
for(int i =0;i<listView.getChildCount();i++){
View layout = listView.getChildAt(i);
//int text = layout.getChildAt(1).getId();
int text = (((ViewGroup) layout).getChildAt(1)).getId();
rgp = (RadioGroup)findViewById(text);
rbtn = (RadioButton)findViewById(rgp.getCheckedRadioButtonId());
Toast.makeText(getApplicationContext(), ""+rbtn.getText().toString(),Toast.LENGTH_SHORT).show();
}
}
});
使用基本适配器和自定义视图 – Giridharan
请参阅本http://developerandro.blogspot.in/2013/09/ listview-with-checkbox-android-example.html –
@Giridharan我有我的代码我想知道y它只显示每次选择的第一个值。 –