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 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
  • 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-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 am new at android development and java programming, but I have decided to
I have done Java and JSP programming in the past, but I am new
I'm new to Java programming, I am programming Java 1.6 with Android. I have
I'm rather new to both Java programming and to Android development, so my learning
I'm completely new to Eclipse/Java/Android programming, so this might sound like a dumb question,
I have an Android application (java) that was working fine when compiled with the
I'm programming on Android, but I guess this is a general Java 101 question...
I'm new to Android and Java programming and I've manage to create a simple
Let me start by saying, I am new to Java programming. I have coded
I'm fairly new in Android/Java programming, so some of the basic stuff is still

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.