How to Increase and Decrease the Integer Value When the Button is Clicked
http://www.viralandroid.com/2015/10/how-to-increase-and-decrease-integer-value-when-the-button-is-clicked.html
In this tutorial, I will show how to increase and decrease the integer value when the button is clicked. Here, the default value is 0 and when you click the plus button the integer value is increased by one and when you click the negative button the integer value is decrease by one.
Related:
How to Increase the Integer Value When Screen is Touched
How to Add Ripple Effect/Animation to a Android Button
How to Embed YouTube Video in Android WebView
XML Layout File
Following is the XML layout file with a TextView and two Buttons for plus and minus.
res/layout/activity_main.xml
Java Activity File
Following is the final java code of MainActivity.java file.
src/ MainActivity.java
Now, run your application and click plus and minus buttons.
Output:
Related:
How to Increase the Integer Value When Screen is Touched
How to Add Ripple Effect/Animation to a Android Button
How to Embed YouTube Video in Android WebView
Android Example: How to Make Increase and Decrease the Integer Value When the Button is Clicked
XML Layout File
Following is the XML layout file with a TextView and two Buttons for plus and minus.
res/layout/activity_main.xml
Java Activity File
Following is the final java code of MainActivity.java file.
src/ MainActivity.java
Now, run your application and click plus and minus buttons.
Output: