Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8092195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:14:06+00:00 2026-06-05T20:14:06+00:00

I have 4 string arrays,each of these array’s length is 4. I also have

  • 0

I have 4 string arrays,each of these array’s length is 4. I also have four textviews . Now I want to randomly settext of that array’s indexes in the textviews. I have done this:

ansone.setText(Answera[0]);
anstwo.setText(Answerb[0]);
ansthree.setText(Answerc[0]);
ansfour.setText(Answerd[0]);

but its keeps the same sequence every time I run the application, I want to randomly select the arrays in different textviews like some time ‘ansone’ textview will set the text of Answerb[0], or ‘anstwo’ textview will set the text of Answerd[0] and so on. Thus everytime I run the application the textviews will randomly select the arrays from where it will be set text. How can I make it random?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:14:07+00:00Added an answer on June 5, 2026 at 8:14 pm

    Create an ArrayList array:

    ArrayList<String> tmp = new ArrayList<String>();
    tmp.add(Answera[0]);
    tmp.add(Answerb[0]);
    tmp.add(Answerc[0]);
    tmp.add(Answerd[0]);
    

    And then shuffle it:

    Collections.shuffle(tmp);
    

    Next, just put the result to each textviews:

    ansone.setText(tmp.get(0));
    anstwo.setText(tmp.get(1));
    ansthree.setText(tmp.get(2));
    ansfour.setText(tmp.get(3));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of arrays, each of elements of these is array to.
In Javascript, I have 2 arrays of 15 string elements, each of 0 to
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
I have several string each containing a JSON representation of an array of objects.
I have a custom ListView with two TextViews , I have two string arrays
I have an array with a 14 strings. I want to display each of
I have two identical array lists in java each having a string value and
I have two String arrays a,b. String a [] = {one,two,three}; String b []
I have some String[] arrays, for example: ['a1', 'a2'] ['b1', 'b2', 'b3', 'b4'] ['c1']
I have 3 String arrays with constants. eg: String[] digit = {one, two, three};

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.