Ok right , i asked how to create a random number from 1-100 for android and i came to this
TextView tv = new TextView(this);
int random = (int)Math.ceil(Math.random()*101);
tv.setText("Your Number Is..."+ random );
What this does is create the default kinda “hello world” style text view and says “Your Number Is…. [Then Random Number]
My problem is that i cant change the layout of this text , because it is not defined in XML, if someone could tell me how to change the style , or like make the random number into a string so i could use it for any Textview layout that would be great ..
Thanks 🙂
You could also do something like this.
Define your string in strings.xml like:
Create a TextView in a layout xml:
Then your code would look like:
This will make it a lot easier when you later on would like to change your text or maybe localize your app.