0

So I have been trying to make an app that sort of counts things. Basically its a standard counter app. But, I'm having trouble actually displaying the number. I have the setup for the button:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button android:id="@+id/button_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="+"/>

<Button android:id="@+id/button_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="-"
    android:layout_below="@+id/button_1" />
</RelativeLayout>

However, I don't know how to actually create the display of the number increasing or decreasing in java. I've read on some places on how to change text with EditText and TextView, but how would I be able to do that with integers? As in, if the number displayed is 5, how can it be so that I also have an int or float with the same value?

TL;DR: How do I make a counter app? Additionally, How can I make the number displayed be a variable rather than text/a string?

Baby
  • 5,062
  • 3
  • 30
  • 52

1 Answers1

0

you have to use String.valueOf("Your content") which will convert following values to string : boolean, char, char[], long, float, double, integer Object;

Anjali
  • 1
  • 1
  • 13
  • 20