android customize gallery focus problem

Posted by Faisal khan on Stack Overflow See other posts from Stack Overflow or by Faisal khan
Published on 2010-06-16T09:38:59Z Indexed on 2010/06/16 9:42 UTC
Read the original article Hit count: 675

Filed under:
|
|
|

Gallery With reference to the following link

http://www.anddev.org/novice-tutorials-f8/a-android-widget-gallery-example-t332-60.html

In above link they are actually animating selected item of the gallery

but i want to change the picture when it is selected, for that i am having following code.

Problem is when i use roller ball to scroll gallery from left to right or right to left to right after scroll on image focus automatically shift to next widget.

   public class SizingGallery extends Gallery{

        public SizingGallery(Context context, AttributeSet attrs) {
            super(context, attrs);
        }


        @Override
        protected boolean getChildStaticTransformation(View child, Transformation t) {
            t.clear();
            ImageView selectedChild = (ImageView) getSelectedView();
            ImageView iv = (ImageView) child;
            BrowseMapCategoryRow cr = (BrowseMapCategoryRow) iv.getTag();

//Following line change the image resource that causing defocus gallery
iv.setImageResource((iv == selectedChild)?cr.getSelectedImgSrc():cr.getUnSelectedImgSrc());
            return true;
        }
    }

© Stack Overflow or respective owner

Related posts about android

Related posts about focus