Android 弹出popupWindow中嵌套viewPager和PagerSlidingTabStrip出现的错误

sungeAndroid 2017-05-09 02:39:28
先上错误信息

我的代码
是个自定义的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);
}

谢谢大佬的帮助
...全文
535 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
这是源码考虑不周 popuwindow 嵌套viewpager会报找不到 viewpager的错误
sungeAndroid 2017-05-17
  • 打赏
  • 举报
回复
加入了fragment集合,我最后没用用弹出window,又开启了一个Activity就没有这问题了
lixuce1234 2017-05-10
  • 打赏
  • 举报
回复
你这个viewpager的适配器有没有添加fragment的集合啊?

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧