2010-10-19 32 views
0

我跟着ApiDemo創建了一個圖庫。沒有背景的android圖庫

,但我並不需要每個項目的背景,所以我標誌着這些代碼:

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

然後,我遇到了一個問題:

默認的第一選擇的項目(也是第一項)是光明的,

但開始拖累,以及所選擇的項目後改變,所有物品看上去暗.....

我不知道如何設置阿爾法回來,讓該項目看起來很明亮.......有人可以幫助我嗎?

回答

3

嘗試設置ListView的cacheColorHint。 IE與

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

編輯:

不要註釋掉這些行,但在Gallery1_android_galleryItemBackground樣式爲@android:color/transparent,或者你想要其它顏色的設置android:background

+0

我想我使用的是一個庫組件,而不是一個listview @@ ..... – peterlawn 2010-10-19 09:28:21

+0

看到我的編輯 – Mannaz 2010-10-19 20:35:15

+0

THX,它確實幫助我使用透明的顏色。 – peterlawn 2010-10-20 04:38:28