Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to clear color of a button?
    primarykey
    data
    text
    <p>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:</p> <pre><code>button.getBackground().setColorFilter(null); </code></pre> <p>Here's my code:</p> <pre><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; } } } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload