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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:16:11+00:00 2026-05-24T22:16:11+00:00

I am trying to pass an integer array to a baseadapter, such that A.class

  • 0

I am trying to pass an integer array to a baseadapter, such that A.class will pass an array of integers to the BaseAdapter in B.class. Here is how I am passing the integer array in A.Class (sender):

int [] mThumb = {
                     R.drawable.image1_thumb, R.drawable.image2_thumb, R.drawable.image3_thumb,
                     R.drawable.image4_thumb, R.drawable.image5_thumb, R.drawable.image6_thumb,
                     R.drawable.image7_thumb, R.drawable.image8_thumb, R.drawable.image9_thumb,
                     R.drawable.image10_thumb};


        Bundle b=new Bundle();
        b.putIntArray("mThumbSent", mThumb);
        Intent startSwitcher = new Intent(A.this, B.class);
        startSwitcher.putExtras(b);

And in my BaseAdapter in activity B:

public class ImageSwitch1 extends Activity Extends ...{
onCreate....
[redacted]
}

private ImageSwitcher mSwitcher;


public class ImageAdapter extends BaseAdapter {

   Bundle b=this.getIntent().getExtras();
    int[] mThumb = b.getIntArray("mThumbSent");

     public ImageAdapter(Context c) {

        mContext = c;
    }

    public int getCount() {

    return mThumb.length; //this used to say return mThumbIds

    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        ImageView im = new ImageView(mContext);
        im.setImageResource(mThumb[position]);
        im.setAdjustViewBounds(true);
        im.setLayoutParams(new Gallery.LayoutParams(
        LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        im.setBackgroundResource(R.drawable.picture_frame);


        return im;
    }

    private Context mContext;

}
}

now obviously the code above is incorrect, I cannot use getintent in the imageadapter. But this is an illustrative example of what I am trying to accomplish, and would like to know how to pass a variable or array via intent to a BaseAdapter, if possible.

  • 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-24T22:16:11+00:00Added an answer on May 24, 2026 at 10:16 pm

    Update the constructor of your ImageAdapter to accept an integer array like so:

    int[] mResources;
    
    public ImageAdapter(Context c, int[] resources) {
        mResources = resources;
        mContext = c;
    }
    

    Then when initializing your Adapter in your Activity, just pass it the extra int array:

    ImageAdapter adapter = new ImageAdapter(context, intArray);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass an array of integers from c# to c++ via a
I'm trying to pass an array of unsigned integers from C++ to Ada. The
I'm having problems trying to pass an Integer object from a driver class as
im trying to pass two parameters to a function, i being an int value
I am trying to pass a member function within a class to a function
I'm trying to pass one method to another in elisp, and then have that
I'm trying to pass a complex object (that can be serialized, if that helps)
I'm trying to pass an instance of a class between two separate classes, like
I'm trying to write a class that has a generic member variable but is
I'm trying to develop an application that will simulate a route through Google's Navigation

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.