I want make a listview which have five item. every item in first 3 are just radio with checkbox are GONE and in list 2 checkbox and radio are GONE. i want when click on radio other 2 radio are uncheck and checkbox remain same if check or uncheck remain same and when i click on check box if checkbox already check that shoud be uncheck but all other radio and checkbox not change they should be remain same and if i check on other checkbox it also works alone please help me.
i have issue is that when i click on radio other check box shoud bhe change but i not want to change it shoud be wor[whats][1]
ListAdapter
public class Listadapter extends ArrayAdapter {
private final Activity context;
private final String[] maintitle;
private final String[] describe;
private final Integer[] imgid;
RadioButton rbut;
CheckBox cBox1;
int checkBox=2;
ArrayList<String> arrayList2;
ArrayList<Integer> checkList;
int selectedRbtPos=-1;
Boolean checkboxflag=false;
// boolean[] itemChecked;
public Listadapter(Activity context, String[] maintitle, String[] describe, Integer[] imgid,ArrayList<String>arrayList2) {
super(context,R.layout.list_item,maintitle);
this.context = context;
this.maintitle=maintitle;
this.describe=describe;
this.imgid=imgid;
this.arrayList2=arrayList2;
checkList = new ArrayList<Integer>();
// itemChecked = new boolean[packageList.size()]; }
public View getView(int position,View view,ViewGroup parent){
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.list_item, null,true);
TextView titleText = (TextView) rowView.findViewById(R.id.textView1);
ImageView imageView = (ImageView) rowView.findViewById(R.id.imgid);
TextView describeText = (TextView) rowView.findViewById(R.id.textView2);
RadioButton rbut=rowView.findViewById(R.id.rbut);
cBox1=rowView.findViewById(R.id.cBox1);
titleText.setText(maintitle[position]);
imageView.setImageResource(imgid[position]);
describeText.setText(describe[position]);
if (selectedRbtPos==position){
rbut.setChecked(true);
titleText.setTag(maintitle[selectedRbtPos]);
String b = titleText.getTag().toString();
arrayList2.add(b);
}
else
if (position<2)
rbut.setChecked(false);
if( cBox1.isChecked())
cBox1.setChecked(true);
else
cBox1.setChecked(false);
if (position<2)
cBox1.setVisibility(View.GONE);
if (position>1)
rbut.setVisibility(View.GONE);
cBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkBox = position;
}
});
rbut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedRbtPos = position;
notifyDataSetChanged();
}
});
return rowView;
};
}
Aucun commentaire:
Enregistrer un commentaire