0

我用下面的代码创建了 GelleryView。我的问题是,我不想显示选择的图像,因为当我触摸滚动它时它会发出黄色光。如何禁用此单击或触摸以使黄色选择状态不出现。

public class main extends Activity {
/** Called when the activity is first created. */
public Context context=main.this;
public Map< Integer,Drawable> dayMap;

ProgressDialog dialog;
Context con=main.this;
JSONArray json_array;
public static ArrayList<String> image;
public static ArrayList<Bitmap> imageBitmap;
mygallery gallery;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    new DownloadMoreImages().execute();

    gallery = (mygallery) findViewById(R.id.thisgallery);

}

public class AddImgAdp extends BaseAdapter {
    int GalItemBg;
    private Context cont;



    public AddImgAdp(Context c) {
        cont = c;
        TypedArray typArray = obtainStyledAttributes(R.styleable.Gallery1);
        GalItemBg = typArray.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
        typArray.recycle();
    }

    public int getCount() {
        return dayMap.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

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

        imgView.setImageDrawable(dayMap.get(position));

        imgView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        imgView.setBackgroundResource(GalItemBg);
        imgView.setLayoutParams(new mygallery.LayoutParams(340  , 265));

        return imgView;
    }
}

public class mygallery extends Gallery {

public mygallery(Context ctx, AttributeSet attrSet) {
    super(ctx, attrSet);
    // TODO Auto-generated constructor stub
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){

  return false;  
}

}

4

1 回答 1

0

尝试galleryview.setOnItemclickListener(null);

于 2012-06-27T09:48:12.497 回答