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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:20:06+00:00 2026-06-14T17:20:06+00:00

It’s almost 2 months now for me, coding in java, android especially. I came

  • 0

It’s almost 2 months now for me, coding in java, android especially.
I came into a problem and I’ve been struggling for over two days now.

Basically, I have a database full of strings(url).
I am trying to build an application where I pass the selected (by my query) Urls into the Universal Image Loader and eventually get a Viewpager with all those images that have been downloaded from the UIL.

I have build my own adapter (in order to use it for the ViewPager) but I don’t know how to use the Universal Image Loader and create that ViewPager.

Here is my code:
MenuImages.java

public class Menu_images extends Activity {


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

 Bundle map = getIntent().getExtras();
 String rest_name=map.getString("key");
 String area=map.getString("key2");

 loadGalleryImages(rest_name, area);


 }

private void loadGalleryImages(String rest_name, String area) {
    DatabaseHandler db = new DatabaseHandler(getApplicationContext());
    List<String> images_url = db.getImagesUrl(rest_name, area);

    MyPagerAdapter adapter = new MyPagerAdapter();
    ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);

    myPager.setAdapter(adapter);
    myPager.setCurrentItem(0);

}

MyPagerAdapter.java

public class MyPagerAdapter extends PagerAdapter {

Context context;


private Integer[] Imgid = {
         R.drawable.gallery_photo_1, R.drawable.gallery_photo_3, R.drawable.gallery_photo_1
};

public MyPagerAdapter(List<String> images_url) {
    // TODO Auto-generated constructor stub
}
public int getCount() {
    return Imgid.length;
}

public Object instantiateItem(View collection, int position) {      


    ImageView img = new ImageView(collection.getContext());


    int resId = 0;
    switch (position) {
    case 0:
        resId = Imgid[0];
        break;
    case 1:
        resId = Imgid[1];
        break;
    case 2:
        resId = Imgid[2];
        break;
    }

    img.setImageResource(resId);
    ((ViewPager) collection).addView(img, 0);
    return img;
}
public void destroyItem(View arg0, int arg1, Object arg2) {
    ((ViewPager) arg0).removeView((View) arg2);
}
public boolean isViewFromObject(View arg0, Object arg1) {
    return arg0 == ((View) arg1);
}
public Parcelable saveState() {
    return null;
}

}

DataBaseHandler.java

public List<String> getImagesUrl(String rest_name, String area) {
    List<String> images_url = new ArrayList<String>();

     // Select All Query
       String selectQuery = "a query goes here";


       SQLiteDatabase db = this.getReadableDatabase();
       Cursor cursor = db.rawQuery(selectQuery, null);





    // looping through all rows and adding to list
       if (cursor.moveToFirst()) {
           do {
               images_url.add(cursor.getString(cursor.getColumnIndex("_images")));
           } while (cursor.moveToNext());
       }

       // closing connection
        cursor.close();
        db.close();

       return images_url;
}

As you can see, I am getting a List with all the String(urls) from the DataBaseHandler.
I actually need to remove the array Interger[] from my MyPagerAdapter and replace it dynamically with the List that I retrieve from my DataBaseHandler (the one with the URLs).

To sum up with, I am trying to make Universal Image Loader use all the URL I pass to it and create a viewpager with those.

I would be eternally grateful, if you could give me a hand with that, cause I am starting to freak out. I have spend many days on this part, searching for hours and haven’t found something that suits me.

Thanks in advance and sorry for the long talk,
Harris.

  • 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-14T17:20:06+00:00Added an answer on June 14, 2026 at 5:20 pm

    Here is a perfect example for you. Download the source code on the upper right corner, and run the application. You can study the source code, it has all you need. It is a bit advance, don’t freak out. Post questions if you have any.

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

Sidebar

Related Questions

I have been unable to fix a problem with Java Unicode and encoding. The
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I've tracked down a weird MySQL problem to the two different ways I was
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.