How to clear color of a button?

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 green color with opacity. Now when I click next button the same happens but the first button is still set to green. I need it to revert to original color. I tried with: button.getBackground().setColorFilter(null); Here's my code: final OnClickListener clickListener = new OnClickListener() { private Button buttonClicked; public void onClick(View v) { Button button = (Button) v; button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0x003333)); if (buttonClicked == null) { // first button is clicked buttonClicked = button; // only do stuff if buttons are in different layouts } else{ if (!button.getParent ().equals(buttonClicked.getParent())) { // second button is clicked if(buttonClicked.getTag().equals(button.getTag()) ){ // second button is clicked and same tag but different button Toast.makeText(Spojnice.this, "Correct", Toast.LENGTH_SHORT).show(); button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0x66FF33)); buttonClicked.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0x66FF33)); buttonClicked.setEnabled(false); button.setEnabled(false); buttonClicked = null; } else { //reset LightingColorFilter first Toast.makeText(Spojnice.this, "Wrong", Toast.LENGTH_SHORT).show(); buttonClicked = null; } }else{ buttonClicked = button; } } } };
Similar question is answered in this post. Please check [Clear Button Color][1] [1]:…

以上就是How to clear color of a button?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准