I'm receiving a series of data from the database and displaying it in a layer that consists of a checkbox and a few other views.In fact, I've made a controlling custom. My question is how can I turn on the checkbox of that layer when clicked on any layer , and the rest are turned off.
public class myclass extends LinearLayout {
LinearLayout linear;
public int id;
public static ImageView pic;
public static TextView titlepro;
public static CheckBox rdb;
public myclass(Context context) {
super(context);
init(context);
}
public myclass(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public myclass(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
public void init(Context context){
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=inflater.inflate(R.layout.linear,this,true);
linear=(LinearLayout)findViewById(R.id.linear2);
pic=(ImageView)view.findViewById(R.id.pic);
titlepro=(TextView)view.findViewById(R.id.txt1);
rdb=(CheckBox)view.findViewById(R.id.rdb1);
rdb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
}
}
});
linear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (rdb.isChecked()){
rdb.setChecked(false);
}else {
rdb.setChecked(true);
}
Toast.makeText(G.context,id+"",Toast.LENGTH_LONG).show();
}
});
}}
My problem is that when you click on a layer, the checkbox for the other layer is checked
Aucun commentaire:
Enregistrer un commentaire