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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:27:05+00:00 2026-06-08T08:27:05+00:00

Good day, please could somebody help me find out what’s wrong with my code.

  • 0

Good day, please could somebody help me find out what’s wrong with my code. I am probably missing something. Nothing is displayed from my CursorAdapter.
Have been struggling with here for some time now.
Any help will be highly appreciated!!

public class ManageTagFragment extends Fragment implements LoaderCallbacks<Cursor> {

    private static String TAG = "Image_Debugger";
    private static final int IMAGE_LOADER = 0;
    TextView text;
    GridView grid;
    CustomGridImageAdapter imageAdapter;
    Cursor cursor;
    ImageDB dbadapter;
    private Cursor c;

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        dbadapter = new ImageDB(getActivity().getApplicationContext());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.wallpaper_images, container, false);      
        grid = (GridView)view.findViewById(R.id.gridview);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);    
        imageAdapter = new CustomGridImageAdapter(getActivity(), null, 0);
        grid.setAdapter(imageAdapter);
        imageAdapter.notifyDataSetChanged();
        getActivity().getSupportLoaderManager().initLoader(IMAGE_LOADER, null, this);
    }

    @Override
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        return new CustomCursorLoader(getActivity().getApplicationContext(), dbadapter, ImageDB.IMAGES);
    }

    @Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        imageAdapter.swapCursor(data);
    }

    @Override
    public void onLoaderReset(Loader<Cursor> args) {
        imageAdapter.swapCursor(null);  
    }

    public static final class CustomCursorLoader extends SimpleCursorLoader {

        String columnname;
        ImageDB dbadapter;
        ArrayList<String> imageuri = new ArrayList<String>();

        public CustomCursorLoader(Context context, ImageDB dbadapter, String columnname){
            super(context);
            this.dbadapter = dbadapter;
            this.columnname = columnname;
        }

        public CustomCursorLoader(Context context,String columnname){
            super(context);
            this.columnname = columnname;

        }

        @Override
        public Cursor loadInBackground() {
            Cursor cursor = null;
            dbadapter.open();

            Log.d(TAG, "retrieving Images from database now");
            cursor = dbadapter.retrieveTag(columnname);

            if(cursor.moveToFirst()){
                 final int index = cursor.getColumnIndex(columnname);

                do {
                    final String val = cursor.getString(index); // this is just
                                                                // for test
                    if (val != null) {
                        Log.d(TAG, "files are" + val);
                        imageuri.add(val);
                    }

                } while (cursor.moveToNext());
            }   
            return cursor;
        }
    }
}

CustomGridImageAdapter.java:

public class CustomGridImageAdapter extends CursorAdapter {
    private static String TAG = "Image_Debugger";
    private LayoutInflater inflater;
    private int count;

    public CustomGridImageAdapter(Context context, Cursor cursor, int flags) {
        super(context, cursor, flags);
        inflater = LayoutInflater.from(context);
        Log.d(TAG, "calling grid imageadapter now");
    }

    @Override
    public int getCount() {
        return count;
    }

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

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

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        Log.d(TAG, "calling bind view");
        ViewHolder holder = (ViewHolder) view.getTag();
        String name = cursor.getString(cursor
                .getColumnIndexOrThrow(ImageDB.IMAGES));
        Log.d(TAG, "string name in gridimageadapter is" + name);

        BitmapFactory.Options options = new BitmapFactory.Options();
        Bitmap bitmap = BitmapFactory.decodeFile(name);

        Bitmap newbitmap = Bitmap.createScaledBitmap(bitmap, 120, 120, false);
        holder.image.setImageBitmap(newbitmap);

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup container) {
        Log.d(TAG, "calling new view here");
        ViewHolder holder = new ViewHolder();
        View view = inflater.inflate(R.layout.media_view, container, false);

        holder.image = (ImageView) view.findViewById(R.id.media_image_id);
        holder.image.setLayoutParams(new GridView.LayoutParams(100, 100));
        holder.image.setScaleType(ImageView.ScaleType.FIT_CENTER);
        view.setTag(holder);

        return view;
    }

    class ViewHolder {
        ImageView image;
        TextView item_name;
    }
}
  • 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-08T08:27:08+00:00Added an answer on June 8, 2026 at 8:27 am

    The problem might be here. Its just an assumption. Sorry if I am wrong.

    @Override
      public int getCount() {
         return count;
      }
    

    What is the value of count here. I don’t find any place where you have passed the value for count.So my assumption is that, the default value for int is returned here (i.e count=0) and hence you don’t find any data in your GridView.

    Could you check that and comment back.

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

Sidebar

Related Questions

Good day, could you please help me look and this code and tell me
Good day. I'm still learning GWT so please help me. I'm working on a
Good day. I could really use your help on this one. I have a
Good day. Please, help me about how to use three methods BeginExecuteReader() of SqlCommand
Good day, please would like to know how to reduce the spaces between the
Good day, I'm puzzled a bit with this: In[1]:= f[x_]:=With[{xx=x},f[xx_]:=ff[xx]] DownValues[f] f[1] DownValues[f] Out[2]=
Good day, I need some help with MS Access and a query. My SQL
I'm not very good at code so please use laymans terms in answering!! I
Good day, please advise. I have a list of items: <List> <Item> <Description>Item 1</Description>
Good day, Hope the tilte is not misleading. please take a look at 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.