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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:08:03+00:00 2026-06-09T00:08:03+00:00

I am using the following to code make an image gallery, but I would

  • 0

I am using the following to code make an image gallery, but I would like to use images from the web instead of from the SD card. Is there a way to do this? Currently the code requires and integer value for the image. Or do I have to download the images to the SD first?

    public class viewimages extends Activity {

private Gallery gallery;
private ImageView imgView;

private Integer[] Imgid = {
        R.drawable.a_1, R.drawable.a_2, R.drawable.a_3, R.drawable.a_4
};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewimages);

    imgView = (ImageView)findViewById(R.id.ImageView01);    
    imgView.setImageResource(Imgid[0]);

     gallery = (Gallery) findViewById(R.id.examplegallery);
     gallery.setAdapter(new AddImgAdp(this));

     gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position, long id) {
            imgView.setImageResource(Imgid[position]); 
        }
    });


}

public class AddImgAdp extends BaseAdapter {
    int GalItemBg;
    private Context cont;

    public AddImgAdp(Context c) {
        cont = c;
        TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
        GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
        typArray.recycle();
    }

    public int getCount() {
        return Imgid.length;
    }

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

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

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imgView = new ImageView(cont);

        imgView.setImageResource(Imgid[position]);
        imgView.setLayoutParams(new Gallery.LayoutParams(80, 70));
        imgView.setScaleType(ImageView.ScaleType.FIT_XY);
        imgView.setBackgroundResource(GalItemBg);

        return imgView;
    }
}

   }
  • 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-09T00:08:04+00:00Added an answer on June 9, 2026 at 12:08 am

    You can do something like this:

    URL url = new URL("http://www.website.com/image.jpg");
    Bimtap bmp = BitmapFactory.decodeStream(url.openConnection()
                        .getInputStream());
    

    Then you’ll need to change where you’re doing “setImageResource” to “setImageBitmap” and supply the ‘bmp’ object once it has been downloaded and loaded up.

    [Edit]

    It’s also important to make sure your android manifest has internet permissions.

    <uses-permission android:name="android.permission.INTERNET" />
    

    [Edit for comment question]

    If you want to do this for multiple images, and the images aren’t based on an id_number (basically if the images aren’t something like 0001.jpg, 0002.jpg, etc.) create a string ArrayList that will hold the names of all the items, and then iterate through it. E.g.,

    List<String> imageNames = new ArrayList<String>();
    imageNames.add("image.jpg");
    imageNames.add("thisPhoto.jpg");
    //etc. until you've added all images
    
    for (int i = 0; i < imageNames.size(); i++){
        URL url = new URL("http://www.website.com/" + imageNames.get(i));
        Bimtap bmp = BitmapFactory.decodeStream(url.openConnection()
                        .getInputStream());
    }
    

    Hope that helps

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

Sidebar

Related Questions

I tried to use the following code to make my ImageButton invisible, but clicking
I am using the following code to make a HttpWebRequest and render the XML
I am using the following code to get make an IMAP connection. I am
I'm using the following code to just make a single UILabel on my cell.
I'm currently facing new problem with operators. Using following code, I want to make
I'm using the following code to try to make a back button for my
I am trying to compile my gcc code using the following make command .
I am using the following code to rotate an uploaded jpeg image if the
I am using the following code to save an image created on a Form
I'm using the following code, but having it fail in IE. The message is:

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.