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

  • Home
  • SEARCH
  • 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 3458884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:02:21+00:00 2026-05-18T10:02:21+00:00

I am new to Java programming / Android development – but I have been

  • 0

I am new to Java programming / Android development – but I have been working through a few examples and have been trying to build a “mix-and-match” app with 3 scrolling galley views.

I have created the relative layout with 3 gallery views, and have defined 3 arrays to contain a list of images.

My problem is that I can’t seem to get the ImageAdapter to set the correct image resource for each gallery view (it duplicates the same images across all 3 galleries).

If I can just post the relevant sections of code:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);

    Gallery gTop = (Gallery) findViewById(R.id.gallery_top);
    Gallery gMid = (Gallery) findViewById(R.id.gallery_mid);
    Gallery gEnd = (Gallery) findViewById(R.id.gallery_end);

    gTop.setAdapter(new ImageAdapter(this));
    gMid.setAdapter(new ImageAdapter(this));
    gEnd.setAdapter(new ImageAdapter(this));
}

Then another class sets the resources (hardcoded):

 public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);
        i.setImageResource(mEndThumbIds[position]);
        i.setAdjustViewBounds(true);
        i.setLayoutParams(new Gallery.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
        );
        return i;
    }

How can I remove this hardcoded link and check to see what object is calling getView and set the image resources accordingly?

Thanks, Alex

  • 1 1 Answer
  • 1 View
  • 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-18T10:02:21+00:00Added an answer on May 18, 2026 at 10:02 am

    How about you add a new constructor to your adapter so that it reads new ImageAdapter(this, Type.END) or new ImageAdapter(this, Type.BEGIN)?

    Of course you would define a enum to make the switch.

    Then, in the constructor simply check which one is requested and set the list.

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

Sidebar

Related Questions

I'm new to Android & Java programming but have been programming in .NET for
I am new at android development and java programming, but I have decided to
I am new to Eclipse and Android programming in general but I have been
I'm fairly new to Android programming and to Java in general, but I have
I'm fairly new to Java and Android programming in general but I would like
I'm still new to programming/Java/Android so I'm trying to understand everything I do and
I am new to Android and Java programming. I have a class which implements
I'm new to Java but not to programming. I'm reading the book Beginning Android
I am new to Android/Java programming. I have two classes, one is an Activity
I'm new to Android programming however I do have some Java experience. What I

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.