Ok, Thank you, that makes sense, I'll have a play and see what I can come up with.

On 02/07/2011 9:13 PM, Kostya Vasilyev wrote:
This has to do with "list view item recycling".

Here is a good tutorial with pictures:

http://android.amberfog.com/?p=296

-- Kostya

03.07.2011 0:10, Simon Platten ?????:
Mark,

When my activity starts the listview is populated and each list view consits of the following row:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
                     android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
                     android:padding="10dp">
<TextView android:id="@+id/tvFilename"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                 android:text="File-name"
                android:textColor="@color/blue"
                android:textStyle="bold" />
<ImageView android:id="@+id/ivthumbNail"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_below="@+id/tvFilename"
                  android:layout_marginRight="6dip" />
<CheckBox android:id="@+id/chkUse"
                 android:layout_width="100dip"
                 android:layout_height="wrap_content"
                 android:layout_below="@+id/tvFilename"
                 android:layout_alignParentRight="true"
                 android:textColor="@color/blue"
                 android:text="Use"
                 android:checked="true"/>
<RelativeLayout android:id="@+id/llRotationButtons"
                         android:layout_width="fill_parent"
                         android:layout_height="fill_parent"
android:layout_below="@+id/chkUse" android:gravity="right">
<ImageButton android:id="@+id/btnCCW"
                         android:layout_width="48dip"
                        android:layout_height="48dip"
                        android:src="@drawable/ccw_rotate_btn"/>
<ImageButton android:id="@+id/btnCW"
                         android:layout_width="48dip"
                        android:layout_height="48dip"
                        android:src="@drawable/cw_rotate_btn"
                        android:layout_toRightOf="@+id/btnCCW"
                        android:layout_marginLeft="6dip"/>
</RelativeLayout>
</RelativeLayout>

This all works well, when either button btnCCW or btnCW is called, a listener is called that rotates the image view either clockwise or counter-clockwise by 90 degrees, this also works well and I can see that the image in the listview is rotating, however when the row goes out of view the rotation is ignored.

I don't understand what you were saying in your last post, can you please clarify?

Thank you,
Simon




On Sat, Jul 2, 2011 at 3:25 PM, Mark Murphy <[email protected] <mailto:[email protected]>> wrote:

    On Sat, Jul 2, 2011 at 10:14 AM, Simon Platten
    <[email protected]
    <mailto:[email protected]>> wrote:
    > I can't call rotateThumbnail directly from getView as it is the
    result of an
    > onClick from one of the buttons also in the view for that item.

    Then why are you expecting your images to be rotated when you
    return a
    row from getView(), if you are not rotating them?

    > The ImageView that is rotated is from the array that the list
    view uses.

    No, it is not, at least not based on the code that you pasted above.
    Which is good, because maintaining an array of ImageViews would be a
    bad move.

    You are getting your ImageView via:

    ImageView ivThumbnail = (ImageView)v.findViewById(R.id.ivthumbNail);

    This is returning the ImageView from the row (recycled or newly
    inflated). It is not from "the array that the list view uses".

    You are setting the background of this ImageView to a *newly decoded
    bitmap* from your file. That too is sub-optimal code, as it means you
    are performing disk I/O on the main application thread on every
    getView() call, so your scrolling will be sluggish. Moreover, you are
    not rotating the image here, so therefore it will not be rotated,
    since it is a *newly decoded bitmap*.

    If you want to rotate your image, then please rotate your image.

    --
    Mark Murphy (a Commons Guy)
    http://commonsware.com | http://github.com/commonsguy
    http://commonsware.com/blog | http://twitter.com/commonsguy

    _Android Programming Tutorials_ Version 3.5 Available!

    --
    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]
    <mailto:[email protected]>
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:android-developers%[email protected]>
    For more options, visit this group at
    http://groups.google.com/group/android-developers?hl=en




--
Regards,
Sy

--
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

--
Kostya Vasilyev
--
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

--
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