java - android button continuously generate strings -


when press button prints 1 of strings @ random, can once have restart app , press again print new one. have able continuously press button , continuously print strings @ random?

public string converse = randomstarter();  public string randomstarter() {     random generator = new random();     int rand = generator.nextint(6);     string starter = new string("");      switch (rand) {         case 0: starter = "what favorite subject in \n school kid? \n worst?";              break;          case 1: starter = "my favorite room in house is...";             break;          case 2: starter = "if had 1 million dollars, it?";             break;          case 3: starter = "did ever have nickname? \n if so, it?";             break;          case 4: starter = "if had magical powers would...";             break;          case 5: starter = "if invisible day, \nwhat do?";             break;          case 6: starter = "5 people not meet...";             break;     }      return starter; } 

xml code text field:

   <textview android:id="@+id/fullscreen_content"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:keepscreenon="true"     android:textcolor="#2f4b66"     android:textstyle="bold"     android:textsize="50sp"     android:gravity="center"     android:text="@string/dummy_content" /> 

your code's hinting use converse 'random' string. if want generate new random stings, you'll have call randomstarter() every time.

if not case, please show code you're using random string.


Comments

Popular posts from this blog

rest - Spring boot: Request method 'PUT' not supported -

php - Magento - Deleted Base url key -

symfony - imagine_filter() not generating the correct url in LiipImagineBundle -