大佬教程收集整理的这篇文章主要介绍了android – 无法在PopupWindow中为GridView执行OnItemClick,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
下面是我的适配器的代码和包含gridView的弹出视图.谢谢!
//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(); } });
以上是大佬教程为你收集整理的android – 无法在PopupWindow中为GridView执行OnItemClick全部内容,希望文章能够帮你解决android – 无法在PopupWindow中为GridView执行OnItemClick所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。