Re: [android-developers] getting the current image by resource or filename from Gallery
Replying to the list...
On Mon, May 30, 2011 at 2:03 PM, Jim Graham <spooky130u@gmail.com> wrote:
> On Mon, May 30, 2011 at 01:54:57PM -0400, Mark Murphy wrote:
>> On Mon, May 30, 2011 at 1:51 PM, Jim Graham <spooky130u@gmail.com> wrote:
>> > Wouldn't getSelectedItemId() return the image resource (i.e.,
>> > R.drawable.foo)?
>>
>> No, it would return the _ID column from the Cursor you used with your
>> CursorAdapter, if you are using a CursorAdapter.
>
> Nope. I'm working from the example in the SDK samples, just trying
> to learn what's going on inside.
Then don't use getSelectedItemId().
> Unless I'm even more confused than I already know I am, this is where
> the image is loaded in the gallery:
>
> public View getView(int position, View convertView, ViewGroup parent) {
>
> ImageView i = new ImageView(mContext);
>
> i.setImageResource(mImageIds[position]);
> i.setLayoutParams(new Gallery.LayoutParams(-1, -1));
> i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
> i.setBackgroundResource(mGalleryItemBackground);
>
> return i;
> }
Use getSelectedItemPosition() to return the index into your mImageIds array.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Android Training in Oslo: http://bit.ly/fjBo24
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home