android customize gallery focus problem
- by Faisal khan
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;
}
}