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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:13:19+00:00 2026-05-30T19:13:19+00:00

i will like to pass pictureActivity.java array to another class imageAdapter.java. I do get

  • 0

i will like to pass pictureActivity.java array to another class imageAdapter.java.
I do get the imgPath result on toast, but i have no idea how to move the string to another class.

PictureActivity.java

ArrayList<HashMap<String, String>> imgList = new ArrayList<HashMap<String, String>>();

    try {
        imageLink = json.getJSONArray(TAG_IMG);

        for(int i = 0; i < imageLink.length(); i++){
            JSONObject c = imageLink.getJSONObject(i);
            String imgPath = c.getString(TAG_PATH);

            HashMap<String, String> map = new HashMap<String, String>();
            map.put(TAG_PATH, imgPath);

            imgList.add(map);
            Toast.makeText(this, map.get(TAG_PATH), Toast.LENGTH_LONG).show();
        }
    }catch (JSONException e) {
        e.printStackTrace();
    }
    ((Gallery) findViewById(R.id.gallery))
            .setAdapter(new ImageAdapter(this));

ImageAdapter.java

public class ImageAdapter extends BaseAdapter {

    private Context myContext;
    public String[] myRemoteImages = {
            //How to add imagepath here??
    };

I wanted to put the array string on myRemoteImages.

  • 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-30T19:13:20+00:00Added an answer on May 30, 2026 at 7:13 pm

    you can pass your array adapter while you initialize the adapter class object:

    ((Gallery) findViewById(R.id.gallery))
                .setAdapter(new ImageAdapter(this, imgList));
    

    and in your adapter class create a constructor like this:

    public class ImageAdapter extends BaseAdapter {
      ArrayList<HashMap<String, String>> data = null;
      public String[] myRemoteImages;
      private Context myContext;
    
      public ImageAdapter(Context context, ArrayList<HashMap<String, String>> data){
       this.mContext = context;
       this.data = data;
    
       myRemoteImages = new String[this.data.size()];
       for(int i=0; i<this.data.size(); i++){
         HashMap<String, String> map = this.data.get(i);
         myRemoteImages[i] = map.get(TAG_PATH).toString();
       }
    
      }
    }
    

    after getting the ArrayList in your adapter class, you may fetch whatever value you want out from it.

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

Sidebar

Related Questions

I have an array of filenames that i would like to pass to an
i will like to pass the value from DatabaseHandler.java lets say name to mainActivity
I will like to know: I have a scenario. If a user adds a
It seems like I will be needing transaction with MySQL and I have no
I have defined a dictionary that I would like to pass around to various
I have a stored procedure that I would like to pass a string to,
I have changed my thread as my last thread also same like that. But
I have a view that will look like this: I'm trying to figure out
I would like to create an initialisation method for a Java class that accepts
Suppose I have some code like this: class Visitor { public: Visitor(callBackFunction) {} void

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.