0

我在我的项目中使用全屏画廊,并且画廊我正在使用画廊的支持基础适配器现在我必须使画廊禁用/停止画廊的滚动,直到在按钮单击时显示弹出窗口任何人都可以帮助我解决这个问题?

--> 下面是使用库的基本适配器而不是扩展库的片段。

public class SubItemSelectedImageAdapter extends BaseAdapter {

    int mGalleryItemBackground;
    private Context mContext;
    private String[] mImageIds;
    ImageView[] mImages;

    public SubItemSelectedImageAdapter(Context c, String[] mImageIds2) {

        mImageIds = mImageIds2;
        mImages = new ImageView[mImageIds.length];
        mContext = c;
        TypedArray attr = mContext
                .obtainStyledAttributes(R.styleable.HelloGallery);
        attr.recycle();
    }

    public int getCount() {
        return mImageIds.length;
    }

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

    public long getItemId(int position) {


        return position;
    }


    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        ImageView imageView = new ImageView(mContext);

        imageView.setImageURI(Uri.fromFile(new File(mImageIds[position])));
        imageView.setLayoutParams(new Gallery.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);

        return imageView;
    }
}

public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub

}

public void beforeTextChanged(CharSequence s, int start, int count,
        int after) {
    // TODO Auto-generated method stub

}

public void onTextChanged(CharSequence s, int start, int before, int count) {
    // TODO Auto-generated method stub

}

}

并 delaring Gallery 对象并从 xml 引用它...

    // full screen gallery implementation.
    ImageAdapter = new SubItemSelectedImageAdapter(this, data);
    Gallery gallery = (Gallery) findViewById(R.id.gallery);

    gallery.setAdapter(ImageAdapter);
4

2 回答 2

1
use setOnTouchListener() of gallery as below and use flag for the enable disable process 
- on popup being display make flag false and when there is no popup being displayed make flag false. 
- code is as below: 
gallery.setOnTouchListener(new OnTouchListener() 
{ public boolean onTouch(View v, MotionEvent event)
 { // TODO Auto-generated method stub
 if(flag==true){ return false;
 }else{
 return true; 
}
 }
 });
于 2012-04-17T05:36:04.583 回答
0

在您的按钮单击事件中,您可以通过以下代码禁用图库。

gallery.setEnabled(false);

这将使它不可点击,也不能滚动。当您完成弹出窗口时,启用。

 gallery.setEnabled(true);
于 2012-04-16T10:51:31.120 回答