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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:26:15+00:00 2026-06-01T20:26:15+00:00

I am getting dynamic length of the string array and I want to display

  • 0

I am getting dynamic length of the string array and I want to display images in the imagebutton and that too in horizontal view as I had added button but it shows in the vertical layout. This is my code:

for (int i =0;i<adapt_objmenu.image_array.length;i++){
    ImageButton b1 = new ImageButton(myrefmenu);
        b1.setId(100 + i);

       // b1.setText(adapt_objmenu.city_name_array[i]);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        if (i > 0) {
            lp.addRule(RelativeLayout.BELOW, b1.getId() - 1);
        }   
        b1.setLayoutParams(lp);
        relative.addView(b1);

    //relate.addView(b1, i,  new RelativeLayout.LayoutParams(width,height));

    //height = height+80;
}
  • 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-01T20:26:16+00:00Added an answer on June 1, 2026 at 8:26 pm

    Use this in your Third Line for set Image for ImageButton.

      for (int i =0;i<adapt_objmenu.image_array.length;i++){
         ImageButton b1 = new ImageButton(myrefmenu);
            b1.setId(100 + i);
             b1.setImageResource(R.drawable.imagename);
           // b1.setText(adapt_objmenu.city_name_array[i]);
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            if (i > 0) {
                lp.addRule(RelativeLayout.RIGHT_OF, b1.getId() - 1);
            }   
            b1.setLayoutParams(lp);
            relative.addView(b1);
    
    //relate.addView(b1, i,  new RelativeLayout.LayoutParams(width,height));
    
    //height = height+80;
    
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting ember to render a dynamic child view. It seems that
I need a multidimensional array of chars that is dynamic in only one dimension...
I have movie clip in an array (newStep) that is being added to the
I am making an app in which i am getting an array of images
I have a default array for example a=[and,a,in,&] etc... Iam getting a dynamic text,
After getting a List<dynamic> object from the linq query, I want to traverse through
I have a doubt in listview android. I am getting 3 dynamic values from
I am designed a dynamic table for getting input from user. Each column of
I am putting together a dynamic photo gallery and getting stuck trying to place
Getting started with TDD and I want to ground up a Repository-driven Model. However,

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.