How to clear color of a button?

前端 未结 1 956
攒了一身酷
攒了一身酷 2021-01-17 06:42

Not only how to clear color to default color of my button, but also in what moment in my code to do it? I\'ve tried everything but no luck. When I click a button I set some

1条回答
  •  渐次进展
    2021-01-17 07:20

    I just made a simple program which toggles the light filter on and off.

    Here is the Activity:

     Button buttonClicked = null;
         @Override
         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.main);
         }
    
         public void clickedButton(View v) {
             Button button = (Button)v;
             button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF,
                                                                           0x66FF33));
    
             if (buttonClicked != null) {
                 buttonClicked.getBackground().setColorFilter(null);
             }
             buttonClicked = button;
    
         }
    

    and here is the XML

    
    
        
        

    0 讨论(0)
提交回复
热议问题