-3

I would like to make the text of a button bold and unbold when clicked. I can get the text to bold when clicked, but it stays bolded. How do you get it to unbold? I looked at using a StateListDrawable, but I am not using images so I am wondering if there is an easier way?

dakshbhatt21
  • 3,558
  • 3
  • 31
  • 40
Veronica
  • 35
  • 3
  • 2
    Try searching before posting. This will help you - http://stackoverflow.com/questions/2682051/android-how-to-make-button-text-bold-when-pressed-or-focussed – Ayush Goyal Jul 23 '13 at 09:44
  • Set tag to a button. if its 0 then you need to make bold. and change its tag to 1. and when you click again you will get tag 1 so change text as normal and set tag again as 0. – Armaan Stranger Jul 23 '13 at 09:47

1 Answers1

1
    Button b;
    b.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
                           if (hasfocus){
                               //Stuff done when clicked
                           } else {
                               //Stuff done when unclicked
                           }
        }
    });
JesusS
  • 1,645
  • 1
  • 18
  • 31