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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:54:47+00:00 2026-06-13T22:54:47+00:00

Am trying to change this answer in this Link below Gridview Tutorial problems To

  • 0

Am trying to change this answer in this Link below
Gridview Tutorial problems

To display Images from a specific folder unto gridview layout. Am sure i broke it..check out the code and the log cat…

 package nsixty.crew.app;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;

public class ImageAdapter45 extends BaseAdapter {

    private Context mContext;


    public ImageAdapter45(Context c) {
        mContext = c;
    }

    public int getCount() {
        return mThumbIds();
    }

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

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

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) { // if it's not recycled, initialize some
                                    // attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

//      File path = new File(Environment.getExternalStorageDirectory(),"/Crews/Images/");
//      String paths = null;
//       
//      if(path.exists())
//      {
//          
//      
//      
//      
//      String[] fileNames  = path.list();

        //Log.d("I be mumu", data);

        ///after you use your images
//      System.gc();
        //Bitmap mBitmap = null;
        //for(int i = 0; i < fileNames.length; i++)
        //{
//          Boolean finish = true;
//          
                //paths = (path.getPath() + "/" + fileNames[i]);
//              BitmapFactory.Options opts=new BitmapFactory.Options();
//              opts.inDither=false;                     //Disable Dithering mode
//              opts.inPurgeable=true;        
//              opts.inPurgeable=true;                   //Tell to gc that whether it needs free memory, the Bitmap can be cleared
//              opts.inInputShareable=true;              //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
//              opts.inTempStorage=new byte[32 * 1024];

                    //System.gc();

        File path = new File(Environment.getExternalStorageDirectory(),
                "/Crews/Images/");
        String paths = null;
        // String[] fileNames = null ;

        StringBuilder sb = new StringBuilder();

        if (path.exists()) {
            //ArrayList<String> urls = new ArrayList<String>();
            String[] fileNames = path.list();
            //List<String> urls =(Arrays.asList(fileNames));

//          for (int i = 0; i < fileNames.length; i++) {
////                sb.append((path.getPath() + "/" + fileNames[i]) + "\n");
//              paths = ((path.getPath() + "/" + fileNames[i]));
//              urls.add(paths);
//              
//              //Log.v("YELLLO12",urls.toArray().toString());
//               
//              
//              
//          }
//          urls.add(paths);

//          String paths3 = "";
//
//          for (String s : urls)
//          {
//               paths3 += s + "\n";
//               
//              // imageView.setImageBitmap(BitmapFactory.decodeFile((path.getPath() + "/" + paths3)));
//          }
            imageView.setImageBitmap(BitmapFactory.decodeFile((path.getPath() + "/" +fileNames[position])));
            System.gc();
            Log.v("YELLLO1237P",fileNames[position]);

            //imageView.setImageBitmap(BitmapFactory.decodeFile("/mnt/sdcard/Crews/Images/IMG_06_11_2012_01_16_05.jpg"));
            //Log.v("YELLLO300",path.getPath() + "/" +paths3);

            //Bitmap mBitmap = BitmapFactory.decodeFile(paths3);
            //imageView.setImageBitmap(mBitmap);
            //Log.v("YELLLO123",paths);
            //Log.v("YELLLO124ggh",fileNames.toString());


        }
        //path.close();


                // }

            //fos.close();








        return imageView;
    }
    //static String data = ImageAdapter45.data3();


    //static String[] mThumbIds = {data};
//  public static String Pathss(){
//      File path = new File(Environment.getExternalStorageDirectory(),"/Crews/Images/");
//      String paths = null;
//      String[] fileNames = null ;
//      
//      StringBuilder sb = new StringBuilder();
//      if(path.exists())
//      {
//          fileNames = path.list();
//          
//          for(int i = 0; i < fileNames.length; i++)
//          {
//              sb.append((path.getPath()+"/"+ fileNames[i]));
//              paths = sb.toString();
//          }
//          
//      }
//      return paths.trim();
//  }

    public Integer mThumbIds() {
        File path = new File(Environment.getExternalStorageDirectory(),"/Crews/Images/");
        //String paths = null;
        String[] fileNames = null ;
        if(path.exists())
        {
            fileNames = path.list();


        }





        return fileNames.length;

        //Log.d("I be mumu", data);

//      StringBuilder sb = new StringBuilder();
//      for(int i = 0; i < fileNames.length; i++)
//      {
//          //Boolean finish = true;
//          //if (finish == true){
//              String  paths = (path.getPath() + "/" + fileNames[i]);
//              sb.append
//              //Log.d("o men see fuckup", paths);
//              
//              // }
//          //fos.close();
//          
//      
//      }
//      




    }


    // references to our images

}

The Images print the same images sometimes.. sometimes it does not display, the log.d prints the path three times. Sometimes i have Bitmap memory oversized or Vm memory full(this is not my immediate problem)
log cat below

11-06 05:58:43.282: I/dalvikvm(1474): Could not find method android.widget.LinearLayout.setAlpha, referenced from method com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout.setAlpha
11-06 05:58:43.282: W/dalvikvm(1474): VFY: unable to resolve virtual method 3671: Landroid/widget/LinearLayout;.setAlpha (F)V
11-06 05:58:43.282: D/dalvikvm(1474): VFY: replacing opcode 0x6f at 0x000a
11-06 05:58:43.282: D/dalvikvm(1474): VFY: dead code 0x000d-000d in Lcom/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout;.setAlpha (F)V
11-06 05:58:43.282: I/dalvikvm(1474): Could not find method android.widget.LinearLayout.setTranslationX, referenced from method com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout.setTranslationX
11-06 05:58:43.282: W/dalvikvm(1474): VFY: unable to resolve virtual method 3677: Landroid/widget/LinearLayout;.setTranslationX (F)V
11-06 05:58:43.282: D/dalvikvm(1474): VFY: replacing opcode 0x6f at 0x000a
11-06 05:58:43.282: D/dalvikvm(1474): VFY: dead code 0x000d-000d in Lcom/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout;.setTranslationX (F)V
11-06 05:58:43.392: W/KeyCharacterMap(1474): No keyboard for id -1
11-06 05:58:43.402: W/KeyCharacterMap(1474): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-06 05:58:43.462: I/dalvikvm(1474): Could not find method com.actionbarsherlock.internal.view.menu.ActionMenuItemView.onHoverEvent, referenced from method com.actionbarsherlock.internal.view.menu.ActionMenuItemView.dispatchHoverEvent
11-06 05:58:43.462: W/dalvikvm(1474): VFY: unable to resolve virtual method 5030: Lcom/actionbarsherlock/internal/view/menu/ActionMenuItemView;.onHoverEvent (Landroid/view/MotionEvent;)Z
11-06 05:58:43.462: D/dalvikvm(1474): VFY: replacing opcode 0x6e at 0x0006
11-06 05:58:43.462: D/dalvikvm(1474): VFY: dead code 0x0009-0009 in Lcom/actionbarsherlock/internal/view/menu/ActionMenuItemView;.dispatchHoverEvent (Landroid/view/MotionEvent;)Z
11-06 05:58:43.502: I/dalvikvm(1474): Could not find method android.widget.LinearLayout.onPopulateAccessibilityEvent, referenced from method com.actionbarsherlock.internal.view.menu.ActionMenuItemView.onPopulateAccessibilityEvent
11-06 05:58:43.502: W/dalvikvm(1474): VFY: unable to resolve virtual method 3667: Landroid/widget/LinearLayout;.onPopulateAccessibilityEvent (Landroid/view/accessibility/AccessibilityEvent;)V
11-06 05:58:43.502: D/dalvikvm(1474): VFY: replacing opcode 0x6f at 0x0006
11-06 05:58:44.163: D/dalvikvm(402): GC_EXPLICIT freed 2K, 54% free 2538K/5511K, external 410K/517K, paused 13074ms
11-06 05:58:44.231: I/ActivityManager(61): Displayed nsixty.crew.app/.ViewPagerFragment: +8s985ms
11-06 05:58:53.015: D/SntpClient(61): request time failed: java.net.SocketException: Address family not supported by protocol
11-06 05:58:53.692: D/dalvikvm(140): GC_EXPLICIT freed 101K, 47% free 3193K/6023K, external 1597K/1823K, paused 2707ms
11-06 05:59:26.372: I/ActivityManager(61): Starting: Intent { act=nsixty.crew.app.GridView34 cmp=nsixty.crew.app/.GridView34 } from pid 1474
11-06 05:59:27.082: V/YELLLO300(1474): /mnt/sdcard/Crews/Images/IMG_06_11_2012_01_16_05.jpg
11-06 05:59:27.082: V/YELLLO300(1474): IMG10_10_2012_01_55_03.jpg
11-06 05:59:27.221: V/YELLLO300(1474): /mnt/sdcard/Crews/Images/IMG_06_11_2012_01_16_05.jpg
11-06 05:59:27.221: V/YELLLO300(1474): IMG10_10_2012_01_55_03.jpg
11-06 05:59:27.241: V/YELLLO300(1474): /mnt/sdcard/Crews/Images/IMG_06_11_2012_01_16_05.jpg
11-06 05:59:27.241: V/YELLLO300(1474): IMG10_10_2012_01_55_03.jpg
11-06 05:59:27.291: V/YELLLO300(1474): /mnt/sdcard/Crews/Images/IMG_06_11_2012_01_16_05.jpg
11-06 05:59:27.291: V/YELLLO300(1474): IMG10_10_2012_01_55_03.jpg
11-06 05:59:27.962: I/ActivityManager(61): Displayed nsixty.crew.app/.GridView34: +1s395ms

Thanks in advance..

  • 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-13T22:54:47+00:00Added an answer on June 13, 2026 at 10:54 pm

    (comments converted to an answer)

    I guess the main problem (apart from the OutOfMemory error) was the incorrect getView which had no dependency towards position. Replacing paths3 with fileNames[position] fixed this.

    Note that you can also retrieve fileNames once in the ImageAdapter45 constructor and use it both in mThumbIds() and getView()

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

Sidebar

Related Questions

I'm trying to change the layout of a databound treeview from this: To this:
I'm trying to work out what regular expression I would need to change this
I am trying to change each parameter of this http://www.exampleofurl.com/search?q=4&e=25;i=8&b=2 through a loop, but
I would have thought this one would be simple but I'm trying to change
I'm trying to update/change contact ringtone using this code: ContentValues values = new ContentValues();
I'm trying to execute this function when a select list's (LevelId0) value change but
I'm trying to get my app to change layouts when the orientation changes. This
I’m trying to make a small change on a CSS for Spiceworks . This
I'm trying to use preg_replace to change the formatting of a TeX file. This
I've got this odd problem with jQuery. I'm trying to let the change of

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.