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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:42:31+00:00 2026-06-11T23:42:31+00:00

For this app I’m trying to write, the idea is that I’m going to

  • 0

For this app I’m trying to write, the idea is that I’m going to host some pictures online and save the individual urls into a sqlite database. Then I will extract each url from the database and download the picture to be shown in a gallery widget. I read about Lazy List (kudos for the great work!) but I’m having problems implementing it. I have tried to modify the coding from Lazy List but it doesnt seem to work. I’m not sure if there is an error in my app or have I modified the Lazy List wrongly. Any help is greatly appreciated and thank you in advance! =)

Code for my app:

public class ResultDetails extends ListActivity {

    protected int foodId;
    protected String pic1, pic2, pic3, pic4, pic5;
    LazyAdapter adapter1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_details);
        foodId = getIntent().getIntExtra("FOOD_ID", 0);
        SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
        Cursor cursor = db.rawQuery("SELECT _id, pic1, pic2, pic3, pic4, pic5 FROM database WHERE _id = ?", new String[]{""+foodId});
    pic1 = cursor.getString(cursor.getColumnIndex("pic1"));
    pic2 = cursor.getString(cursor.getColumnIndex("pic2"));
    pic3 = cursor.getString(cursor.getColumnIndex("pic3"));
    pic4 = cursor.getString(cursor.getColumnIndex("pic4"));
    pic5 = cursor.getString(cursor.getColumnIndex("pic5"));
    String[] mStrings={
            pic1,
            pic2,
            pic3, 
            pic4, 
            pic5};
    Gallery g = (Gallery) findViewById(R.id.photobar);
    adapter1=new LazyAdapter(this, mStrings);
    g.setAdapter(adapter1);
}

I have modified the LazyAdapter as such:

public class LazyAdapter extends BaseAdapter {
   int mGalleryItemBackground;
   private Context mContext;

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 

    public LazyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }
    public LazyAdapter(Context c) {
       mContext = c;
       TypedArray b = c.obtainStyledAttributes(R.styleable.Theme);
       mGalleryItemBackground = b.getResourceId(
         R.styleable.Theme_android_galleryItemBackground,
                   0);
       b.recycle();
   }


    public int getCount() {
        return data.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 vi = new ImageView(mContext);
        imageLoader.DisplayImage(data[position], vi);
        vi.setLayoutParams(new Gallery.LayoutParams(150, 100));
    vi.setScaleType(ImageView.ScaleType.FIT_XY);
        return vi;
    }
}
  • 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-11T23:42:31+00:00Added an answer on June 11, 2026 at 11:42 pm

    With the help of Fedor, I figured out what was wrong with the implementation. Whether for list or gallery, there is no need to change the LazyAdapter! Just use the adapter as it is and use the following code in your app to load the pictures:

     g = (Gallery) findViewById(R.id.photobar);
     adapter1=new LazyAdapter(this, mStrings);
     g.setAdapter(adapter1);}
    

    I noticed that there are a lot of examples on using LazyList for lists and not galleries. To help those who want to use it for galleries, here is an example of the implementation:

    public class ResultDetails extends ListActivity {
    
    protected int foodId;
    protected String pic1, pic2, pic3, pic4, pic5;
    LazyAdapter adapter1;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_details);
        foodId = getIntent().getIntExtra("FOOD_ID", 0);
        SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
        Cursor cursor = db.rawQuery("SELECT _id, pic1, pic2, pic3, pic4, pic5 FROM database WHERE _id = ?", new String[]{""+foodId});
        pic1 = cursor.getString(cursor.getColumnIndex("pic1"));
        pic2 = cursor.getString(cursor.getColumnIndex("pic2"));
        pic3 = cursor.getString(cursor.getColumnIndex("pic3"));
        pic4 = cursor.getString(cursor.getColumnIndex("pic4"));
        pic5 = cursor.getString(cursor.getColumnIndex("pic5"));
        String[] mStrings={pic1, pic2, pic3, pic4, pic5};
        g = (Gallery) findViewById(R.id.photobar);
        adapter1=new LazyAdapter(this, mStrings);
        g.setAdapter(adapter1);}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this app written in VB.Net with winforms that shows some stats and
In this app I want that as I click on button the data from
Part of this app is a Scream button that plays random screams from cast
This app takes todays date adds a number of weeks that the user has
I have this app that monitors you through out the day. When you place
I have this small app that runs on any phone having API level 6
Notice this app: How can I draw that sort of triangle above an existing
I made this app that takes time entries from fogbugz and posts them to
I made this app that is supposed to give an xml document with 5
I have this app of mine that contains a section that will allow the

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.