I know this is a question that has been asked many times before, but I can't seem to solve it in my code. I have two buttons, and when one is pressed, I would like to keep it in its selected state, and vice versa. I have tried doing it using but the setSelected and setPressed, but I can't seem to get it to work. Here is the code I am using:
    region_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            objects = category;
            adap.notifyDataSetChanged();
            proximity_button.setPressed(false);
            region_button.setPressed(true);
        }
    });
    proximity_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            objects = proximity;
            adap.notifyDataSetChanged();
            region_button.setPressed(false);
            proximity_button.setPressed(true);
        }
    });
Edit: Based on the comments, I need to add that I have a custom xml background for the buttons, and would like to retain the current look.
 
     
     
     
     
     
     
    