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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:08:08+00:00 2026-06-11T19:08:08+00:00

So I have a function for an android app that is supposed to take

  • 0

So I have a function for an android app that is supposed to take any number of pictures and display them 5 pics for each row, for some reason when it goes to the second row, it just repeats the pics for the first row, for example if I have 7 pics numbered 1-7 they will display:
12345
12
here is my function, thanks for any advice.

public void generateImageView(int number, String path){
        //ImageView[] imageViewArray = new ImageView[number];
        int ROW_ITEMS = 5; // 5 images per row
        RelativeLayout rl = (RelativeLayout) findViewById(R.id.RelativeLayout1);
        int limit = number;//limits the number of created imageViews to number
        int rows = limit / ROW_ITEMS;//number of rows
        int leftOver = limit % ROW_ITEMS; //see if we have incomplete rows
        if (leftOver != 0){
            rows += 1;
        }
        int id = 1000;
        int belowId = R.id.send;
        while (rows > 0){
            int realItemsPerRow = ROW_ITEMS;
            if (leftOver != 0 & rows == 1){
                realItemsPerRow = Math.min(ROW_ITEMS,  leftOver);
            }

        for (int i = 0; i < realItemsPerRow; i++){

            Bitmap myBitmap = BitmapFactory.decodeFile(path + i + ".png");
            ImageView imageViewArray = new ImageView(MainActivity.this);
            imageViewArray.setId(id);
            imageViewArray.setImageBitmap(myBitmap);
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            imageViewArray.setPadding(10,10,0,0);
            imageViewArray.setAdjustViewBounds(true);
            imageViewArray.setMaxHeight(80);
            imageViewArray.setMaxWidth(80);
            if (i==0) {
                lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
            } else {
                lp.addRule(RelativeLayout.RIGHT_OF, imageViewArray.getId() -1);
            }
            lp.addRule(RelativeLayout.BELOW, belowId);

            imageViewArray.setLayoutParams(lp);

            rl.addView(imageViewArray);
            id++;
        }
        belowId = id - 1;
        rows--;
  • 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-11T19:08:10+00:00Added an answer on June 11, 2026 at 7:08 pm

    It’s because you’re just pulling the same images for each position in the row:

    Bitmap myBitmap = BitmapFactory.decodeFile(path + i + ".png");
    

    Before while( rows > 0 ) add:

    int j = 0;
    

    Then change the above to:

    Bitmap myBitmap = BitmapFactory.decodeFile(path + ( j * ROW_ITEMS + i ) + ".png");
    

    and under rows--; add:

    j++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple android app that has quite a number of buttons, all
I'm writing an android app where you have a recursive function that takes a
I have an android app that a) performs an updateData() function (querying content providers
So I am writing an Android app and want to have a function that
I have a PhoneGap app that I'm testing on webOS, Android, and iPhone. I'm
Ok so I have a simple Android app that I want it to go
I have a Opengl ES 1.x ANdroid 1.5 app that shows a Square with
I have an example Android app that I compiled in Eclipse and installed on
I have a Titanium Android app that I'm developing and recently deployed to the
I have an android app and I would like to implement the search function.

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.