android – 无法在PopupWindow中为GridView执行OnItemClick

android – 无法在PopupWindow中为GridView执行OnItemClick,第1张

概述我有一个gridView,我在d出窗口中显示(gridview是透明布局,继承自linearlayout,只有一个部分透明的背景).我永远无法让这个GridView的OnItemClick执行.当我触摸gridview中的图像时,它似乎被点击(图像bachgrond更改),但OnItemClick未被调用. 下面是我的适配器的代码和包含gridView的d出视图.谢谢! //Adapter 公共类 我有一个grIDVIEw,我在d出窗口中显示(grIDvIEw是透明布局,继承自linearlayout,只有一个部分透明的背景).我永远无法让这个GrIDVIEw的OnItemClick执行.当我触摸grIDvIEw中的图像时,它似乎被点击(图像bachgrond更改),但OnItemClick未被调用.

下面是我的适配器的代码和包含grIDVIEw的d出视图.谢谢!

//Adapter

公共类ImageAdapter扩展BaseAdapter {
    private Context mContext;
    private int itemBackground;

public ImageAdapter(Context c) {    mContext = c;  //---setting the style---    TypedArray a = c.obtainStyledAttributes(R.styleable.gallery1);    itemBackground = a.getResourceID(R.styleable.gallery1_androID_galleryItemBackground,0);    a.recycle();}

….

public VIEw getVIEw(int position,VIEw convertVIEw,VIEwGroup parent) {    ImageVIEw imageVIEw;    if (convertVIEw == null) {        imageVIEw = new ImageVIEw(mContext);    } else {        imageVIEw = (ImageVIEw) convertVIEw;    }    imageVIEw.setimageResource(images[position]);    imageVIEw.setScaleType(ImageVIEw.ScaleType.CENTER_INSIDE);    imageVIEw.setBackgroundResource(itemBackground);    return imageVIEw;}public Integer[] images = {        R.drawable.sound1,R.drawable.sound2,R.drawable.sound3,R.drawable.sound4};

}

//////////In Activity,onCreate////////...final LayoutInflater inflater=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);    final transparentLayout musicGrID = (transparentLayout) inflater.inflate(R.layout.grIDvIEwpopup,null,false);    final GrIDVIEw gVIEw = (GrIDVIEw) musicGrID.findVIEwByID(R.ID.music_grIDvIEw);    gVIEw.setAdapter(new ImageAdapter(this));    final PopupWindow soundSelectorWindow = new PopupWindow(this);    soundSelectorWindow.setContentVIEw(musicGrID);    soundSelectorWindow.settouchable(true);    gVIEw.setonItemClickListener(new OnItemClickListener()     {        public voID onItemClick(AdapterVIEw<?> parent,VIEw v,int position,long ID)         {               //NEVER GETS HERE            soundSelectorWindow.dismiss();        }    });
解决方法 如果删除soundSelectorWindow.settouchable(true)会发生什么? 总结

以上是内存溢出为你收集整理的android – 无法在PopupWindow中为GridView执行OnItemClick全部内容,希望文章能够帮你解决android – 无法在PopupWindow中为GridView执行OnItemClick所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1121683.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存