Do I need to be including any other classes for this to run?  What is a
PuzzleView?  Is that something in Android 2.0?

On Mon, Nov 23, 2009 at 9:59 AM, Jason Mallet-Prevost
<[email protected]>wrote:

> Hi Mihai,
>
> I have an HTC G1 running Android 1.6.  I'm working on getting your new code
> implemented this morning.  I'll let you know how it goes.  And thank you.
>
>
> On Mon, Nov 23, 2009 at 7:56 AM, Mihai Fonoage <[email protected]>wrote:
>
>> Hi Jason,
>>
>> Have you tried the updated version of my code (http://
>> mihaifonoage.blogspot.com/2009/11/displaying-images-from-sd-card-
>> in.html<http://mihaifonoage.blogspot.com/2009/11/displaying-images-from-sd-card-in.html>)
>> ? I am curious if you'll encounter the same problem with it.
>> I am still using MediaStore, so you might. It would also be
>> interesting to know what is wrong with the above code. I remember
>> getting the same behavior on the emulator once, but I deleted the AVD,
>> created a new one, and could not reproduce it afterwards.
>>
>> By the way, what phone are you using, and what version of the SDK do
>> you have on it?
>>
>> Mihai Fonoage
>>
>> On Nov 22, 1:38 pm, JasonMP <[email protected]> wrote:
>> > Hello, I'm testing some code from a demo found in a forum and I'm
>> > getting some strange results.  My goal is to be able to allow users to
>> > access the pictures on their device to choose an avatar/logo.  This
>> > code run flawlessly except that I only get a handful of images on the
>> > phone.  And its not even always the same images.  Whats more is that
>> > it loads those images into a gridview and repeats them for what looks
>> > like a number of times equal to the actual number of images that are
>> > on the device.  And on top of that if I scroll down the through the
>> > pictures, and scroll back up, it reorders the pictures from what they
>> > were previously.  Each time I load the app the pictures seem to be
>> > different as well.  I have around 400 pictures stored on my phone, and
>> > thats what I'm using to test.  If someone could shed some light on
>> > this for me that would be great.  This is my first time using a URI to
>> > access content to I'm not sure where to start troubleshooting this
>> > one.
>> >
>> > public class gallery extends Activity {
>> >
>> >     /**
>> >      * Cursor used to access the results from querying for images on
>> > the SD card.
>> >      */
>> >     private Cursor cursor;
>> >     /*
>> >      * Column index for the Thumbnails Image IDs.
>> >      */
>> >     private int columnIndex;
>> >
>> >     @Override
>> >     public void onCreate(Bundle savedInstanceState) {
>> >         super.onCreate(savedInstanceState);
>> >         setContentView(R.layout.gallery);
>> >
>> >         // Set up an array of the Thumbnail Image ID column we want
>> >         String[] projection = {MediaStore.Images.Thumbnails._ID};
>> >         // Create the cursor pointing to the SDCard
>> >         cursor = managedQuery
>> > ( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
>> >                 projection, // Which columns to return
>> >                 null,       // Return all rows
>> >                 null,
>> >                 MediaStore.Images.Thumbnails.IMAGE_ID);
>> >         // Get the column index of the Thumbnails Image ID
>> >         columnIndex = cursor.getColumnIndexOrThrow
>> > (MediaStore.Images.Thumbnails._ID);
>> >
>> >         GridView sdcardImages = (GridView) findViewById(R.id.sdcard);
>> >         sdcardImages.setAdapter(new ImageAdapter(this));
>> >
>> >         // Set up a click listener
>> >         sdcardImages.setOnItemClickListener(new OnItemClickListener()
>> > {
>> >             public void onItemClick(AdapterView parent, View v, int
>> > position, long id) {
>> >                 // Get the data location of the image
>> >                 String[] projection = {MediaStore.Images.Media.DATA};
>> >                 cursor = managedQuery
>> > ( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
>> >                         projection, // Which columns to return
>> >                         null,       // Return all rows
>> >                         null,
>> >                         null);
>> >                 columnIndex = cursor.getColumnIndexOrThrow
>> > (MediaStore.Images.Media.DATA);
>> >                 cursor.moveToPosition(position);
>> >                 // Get image filename
>> >                 String imagePath = cursor.getString(columnIndex);
>> >                 // Use this path to do further processing, i.e. full
>> > screen display
>> >             }
>> >         });
>> >     }
>> >
>> >     /**
>> >      * Adapter for our image files.
>> >      */
>> >     private class ImageAdapter extends BaseAdapter {
>> >
>> >         private Context context;
>> >
>> >         public ImageAdapter(Context localContext) {
>> >             context = localContext;
>> >         }
>> >
>> >         public int getCount() {
>> >             return cursor.getCount();
>> >         }
>> >         public Object getItem(int position) {
>> >             return position;
>> >         }
>> >         public long getItemId(int position) {
>> >             return position;
>> >         }
>> >         public View getView(int position, View convertView, ViewGroup
>> > parent) {
>> >             ImageView picturesView;
>> >             if (convertView == null) {
>> >                 picturesView = new ImageView(context);
>> >                 // Move cursor to current position
>> >                 cursor.moveToPosition(position);
>> >                 // Get the current value for the requested column
>> >                 int imageID = cursor.getInt(columnIndex);
>> >                 // Set the content of the image based on the provided
>> > URI
>> >                 picturesView.setImageURI(Uri.withAppendedPath(
>> >
>> > MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID));
>> >                 picturesView.setScaleType
>> > (ImageView.ScaleType.FIT_CENTER);
>> >                 picturesView.setPadding(8, 8, 8, 8);
>> >                 picturesView.setLayoutParams(new GridView.LayoutParams
>> > (100, 100));
>> >             }
>> >             else {
>> >                 picturesView = (ImageView)convertView;
>> >             }
>> >             return picturesView;
>> >         }
>> >     }
>> >
>> >
>> >
>> > }
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<android-developers%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to