I’m creating buttons dynamically …
for(int i=0; i<colSize;i++){
final Button btn = new Button(this);
btn.setText(SectionName[i]);
btn.setTextSize(10);
btn.setPadding(8, 3,8, 3);
btn.setTextColor(Color.WHITE);
btn.setTypeface(Typeface.SERIF, Typeface.BOLD);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//***Every time that I click my button is selected !:)
btn.setSelected(true);
}
});
}
But how could I deselect the other buttons that were selected, I just want one Button selected! 🙂
Declare a variable to store the Id of the Clicked Button ::
set an ID on every button when are created ::
or a tag ::
then in that Listener get the “EnabledButton”, and call a function to deselect the other buttons::
The Function to deselect the other Buttons ::