我想在列表视图中隐藏或禁用未选中的单选按钮... 我是这样的:
if (!radioButton.isChecked()){
radioButton.setVisibility(View.GONE);
}
但是它不起作用..现在我不知道该怎么做。...
代码:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater= (LayoutInflater) votingForCVc.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=layoutInflater.inflate(R.layout.cvcitemfile,parent,false);
final TextView checkedTextView = convertView.findViewById(R.id.itemvoting);
final RadioGroup radioGroup=convertView.findViewById(R.id.rdgrp);
checkedTextView.setText(playernmae.get(position));
final View finalConvertView = convertView;
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = finalConvertView.findViewById(R.id.rdbtn);
Integer v = null;
Integer v1 = null;
if (radioButton.isChecked()) {
for (int i = 0; i < player_id.size(); i++) {
v1= Integer.valueOf(player_id.get(position));
v = Integer.valueOf(vote1.get(position));
v += 1;
}
Toast.makeText(votingForCVc, "Thanks For Voting.", Toast.LENGTH_SHORT).show();
}
return convertView;
}
}