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 4062850
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:39:02+00:00 2026-05-20T15:39:02+00:00

HI, I want to display 20 random images at a time over Activity screen

  • 0

HI,

I want to display 20 random images at a time over Activity screen in android. I’m using this snippet:-

ImageView imageArr[] = new ImageView[25];
    int id[]={  R.drawable.letter1,R.drawable.letter2,R.drawable.letter3,R.drawable.letter4,
                R.drawable.letter5,R.drawable.letter6,R.drawable.letter7,R.drawable.letter8,
                R.drawable.letter9,R.drawable.letter10,R.drawable.letter11,R.drawable.letter12,
                R.drawable.letter13,R.drawable.letter14,R.drawable.letter15,R.drawable.letter16,
                R.drawable.letter17,R.drawable.letter18,R.drawable.letter19,R.drawable.letter20};

    ArrayList<Integer> randomArr = new ArrayList<Integer>();
    for(int i=0; i<20;i++) { 
        randomArr.add(i); 
    }
    Collections.shuffle(randomArr);

    for(int i=0; i<20; i++){  
        //ImageView mImageplay = (ImageView)findViewById(R.id.image_play);
        imageArr[i]=(ImageView)findViewById(id[randomArr.get(i)]);
        //mImageplay.setImageResource(id[randomArr.get(i)]);
    }

Here I’m having 20 custom images of size 49×49 pixels(small sizes)in drawable folder which i want to dispaly over UI at a time in random fashion with no alignment.

The problem is in imageArr[i] is showing NULL value for all the 20 images,whereas “randomArr” is having the correct shuffled data.

Also, Is there any way to display it in randomized look in Layout Area as i was not able to find out solution for this.

I am struck in this and not able to resolve it. please help me out for this.

thanks in advance.
-pk

  • 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-05-20T15:39:03+00:00Added an answer on May 20, 2026 at 3:39 pm

    Your array id[] contains R.drawable. values (id of Drawables in your app) instead of R.id. (id of your ImageViews in your layout).

    Set the android:id attributes in your layout, and use them in your id[] array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a web page to display several random images on load. I've thought
I have an array of images that I want to display in a random
What I want to do is to display 5 random images with text out
I have a smarty template, that I want to display a random sentence on
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
In the header of the django admin, I want display a link. This link
I want to display images in a TableView . I can display one image
I want to display result of this javascript in a label control on my
I am trying to display random banner each time the user refresh the page.
I am creating an activity that displays 9 images in a GridView. I want

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.