Display dynamic text in Android view

I am new to Android app development, but I am trying to display the score at the end of the game I am making.

I planned to switch to a view using:

setContentView(R.layout.over); 

And it seems to work, but I want to display the score.

I defined textView:

 <TextView android:text="@+id/TextView02" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 

But I would like to change the text as follows: "Evaluation: (dynamic text from a variable here)." Obviously, I need to somehow refer to this variable or set the text textView before moving on to this view.

Please, help!

+6
source share
3 answers

This should solve your problem:

 TextView tv = (TextView)findViewById(R.id.TextView02); tv.setText("Text to set"); 

Why assign text and id to the same values?

+5
source

Greg Answer a lot of what you want, but tune in to what you are looking for:

  TextView tv = (TextView)findViewById(R.id.TextView02); tv.setText("Score: "+scoreVariable); 
+1
source

I have to use dialog boxes to show Scrore. here ypou has how to create differents dialogs.

http://developer.android.com/guide/topics/ui/dialogs.html

0
source

Source: https://habr.com/ru/post/893523/


All Articles