Android 弹出popupWindow中嵌套viewPager和PagerSlidingTabStrip出现的错误
发布时间:2018-02-01 来源:查字典编辑
摘要:先上错误信息我的代码是个自定义的popupWindowpublicMyPopupWindow(DataQueryActivitydataQu...
先上错误信息
我的代码
是个自定义的popupWindow
public MyPopupWindow(DataQueryActivity dataQueryActivity, Context context, int width, int height){ mActivity = dataQueryActivity; mContext = context; mInflate = LayoutInflater.from(context).inflate(R.layout.view_popupwindow, null); mDm = mContext.getResources().getDisplayMetrics(); initView(); setContentView(mInflate); setBackgroundDrawable(new ColorDrawable(Color.WHITE)); setOutsideTouchable(true); setWidth(width); setHeight(height); setFocusable(true); setAnimationStyle(R.style.popuwindowAnimation); showAtLocation(mInflate, Gravity.CENTER,width,0); }
initView方法
private void initView() { mViewPager = (ViewPager) mInflate.findViewById(R.id.myviewpager); mResuleAdapter = new ResultPagerAdapter(mActivity.getSupportFragmentManager(),tabs); mPagerTabs = (PagerSlidingTabStrip) mInflate.findViewById(R.id.tabs); //设置是否宽度铺满全屏 mPagerTabs.setShouldExpand(true); //设置分割线的透明 mPagerTabs.setDividerColor(Color.TRANSPARENT); //设置底部滚动条的高度 mPagerTabs.setUnderlineHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, mDm)); // 设置Tab Indicator的高度 mPagerTabs.setIndicatorHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, mDm)); //设置滚动条的颜色 mPagerTabs.setIndicatorColor(mContext.getResources().getColor(android.R.color.white)); mViewPager.setAdapter(mResuleAdapter); mPagerTabs.setViewPager(mViewPager); }
谢谢大佬的帮助
回复讨论(解决方案)
你这个viewpager的适配器有没有添加fragment的集合啊?
加入了fragment集合,我最后没用用弹出window,又开启了一个Activity就没有这问题了