I have an int called playerCount in my MainActivity Java file and would like to import it to my XML file, How would I go about doing that?
When I loaded an Java Method I wrote
android:onClick="playSound"
And then,
public void playSound(View view) {
MediaPlayer mediaPlayer = MediaPlayer.create(MainActivity.this, R.raw.sound);
mediaPlayer.start();
}
What I'm trying to say is how do I load an number stored in an integer in an java file to xml? For example
android:text="(the integer would go int here)"
I'm using Arduino Studio messing around and trying to make my first app, I have some experience with Java from before.
Thanks
You don't actually want to put that integer inside your XML file.
Your XML file contains views right? Like
<TextView></TextView>
. These should also contain an id likeandroid:id="@+id/myTextView"
You can give these views certain values you want with methods like
setText();
First find the view by the ID and then set the integer as a text value for theTextView
.