'Disable button for every user and clickable button only for admin
I have a reset button which only admin can click and for users it wil be disabled always meaning only admin can reset counts. How to do it?
@Override
public void onClick(View arg0) {
count10counter=0;
tvcount10.setText ( String.valueOf ( count10counter ) );
}
} );```
Solution 1:[1]
At your activity, get the button by its id and set its visibility to invisible. Paste this code where you implement user log:
Button btn = findViewById (R.id.reset_button); // reset_button is the view id taken from the xml file
btn.setVisibility (View.GONE);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Avital |
