+ 1

A way to stop button function

what is the perfect way to stop button function with java??

22nd Jul 2018, 1:46 PM
Ahmad
Ahmad - avatar
5 Answers
+ 1
I don't exactly understand what you mean, but if you want to disable a Button in an Android-App using Java, you could do something like this: Button button1 = (Button) findViewById(R.id.button1); button1.setEnabled(false); This would disable the button and stop the user from clicking it, but it would still be visible and take its place on the screen.
22nd Jul 2018, 2:50 PM
Azad Ad
Azad Ad - avatar
+ 1
i have coded tic tac toe with netbeans but when the game finished...you can press the button and it works... so i need a way to stop pressing the buttons of the game
22nd Jul 2018, 3:11 PM
Ahmad
Ahmad - avatar
+ 1
I understand what you mean, you could put all buttons into a LinearLayout with id layout1 and then do this: View layout1 = (View) findViewById(R.id.layout1); layout1.setEnabled(false); This should make your code working
22nd Jul 2018, 3:14 PM
Azad Ad
Azad Ad - avatar
+ 1
your welcome i just try to help the people
22nd Jul 2018, 3:17 PM
Azad Ad
Azad Ad - avatar
0
thank you sir
22nd Jul 2018, 3:16 PM
Ahmad
Ahmad - avatar