--ADVERTISEMENT--

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

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:
How to Increase and Decrease the Integer Value When the Button is Clicked

Post a Comment

Powered by Blogger.