android 中出现这种错误的机会有很多,本人这次出现的 原因是:
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popView = inflater.inflate(R.layout.popup_layout, null);
popupWindow = new PopupWindow(popView,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setFocusable(true);
gridView = (GridView)findViewById(R.id.gridView1);
gridView.setOnItemClickListener(new ItemClickListener());
这其中 gridView = (GridView)findViewById(R.id.gridView1);
应该是gridView = (GridView)popView.findViewById(R.id.gridView1);
就是网格组件在popView这个xml文件中,必须加上去