
下面是我的适配器的代码和包含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所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)