tags:

views:

45

answers:

1

Hi all ,

i followed the ApiDemo to create a gallery.

but i don't need the background of each item , so i marked these code:

 public ImageAdapter(Context c) {
            mContext = c;
            // See res/values/attrs.xml for the <declare-styleable> that defines
            // Gallery1.
**//            TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
//            mGalleryItemBackground = a.getResourceId(
//                    R.styleable.Gallery1_android_galleryItemBackground, 0);
//            a.recycle();**
        }


public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mImageIds[position]);
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setLayoutParams(new Gallery.LayoutParams(48, 48));

            // The preferred Gallery item background
           **// i.setBackgroundResource(mGalleryItemBackground);**

            return i;
        }

then , i met a problem :

the default first selected item( also the first item) is bright ,

but after a start to drag , and the selected item be changed , all items looked dark.....

i don't know how to set the alpha back , let the item looks bright.......could someone help me?

+1  A: 

Try set the cacheColorHint of your ListView. IE with

<listView android:cacheColorHint="@android:color/transparent" ...

EDIT:

Do not comment out these lines, but set the android:background in the Gallery1_android_galleryItemBackground Style to @android:color/transparent or another color you want.

Mannaz
i think i'm using a gallery component , not a listview @@.....
peterlawn
see my edit above
Mannaz
thx , it did help me to use a transparent color.
peterlawn
but i need the selected item looks bright , and others dark, could you tell me how to do that?
peterlawn
You have to set a custom `android:listSelector` for your ListView. Create a new question and send me a link to it and i will show you how. Also can i have my question accepted pls ;-), maybe an upvote?
Mannaz