在复用 SmartTabLayout  时, 出现了标题所示的错误。首先我的场景是Activity下两个fragment  :A 和 B,A中使用了SmarttabLayout和viewpager结合, B也同样使用了这个结合, 然后就出现了B中滑动异常或不显示了, 网上的答案有几种情况:

  一. viewpager的id不能相同

  二. getFragmentManager() 改为 getChildFragmentManager(), 简单点说就是即前者只为activity中表层fragment提供服务, 而后者为fragment中的fragment提供服务。

  然而都没有解决我那个情况, 后来慢慢debug, 最终发现将findViewById()前的getActivity()改为getView(), 问题解决了(也需要满足上面两种情况)!

两者区别getView()只提供当前fragment的view, 而getActivity()可以提供整个activity的view。所以建议以后还是用Fragment的getView()来初始化控件吧。

java.lang.IllegalStateException: FragmentManager is already executing transactions 及 SmartTabLayout复用的更多相关文章

  1. java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead

    java.lang.IllegalStateException: Not allowed to create transaction on sharedEntityManager - use Spri ...

  2. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决

    (1)我用的是fragment,在onStop但是没有onDestroy的情况下切换(replace)fragment时报 java.lang.IllegalStateException: Can n ...

  3. myeclipse 无法启动 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).

    把myeclipse10 按照目录完整拷贝到了另外一台电脑, 另外的目录 原安装目录 D\:\soft\i\myeclipse10 新安装目录 E\:\soft\myeclipse10 双击启动失败, ...

  4. java.lang.IllegalStateException:Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx...}: java.lang.IllegalSta ...

  5. java.lang.IllegalStateException: getOutputStream() has already been called for this response

    ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exceptionjava.lang ...

  6. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this response

    1. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this ...

  7. eclipse启动报错java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' befo

    报错: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invo ...

  8. java.lang.IllegalStateException: Couldn't read row 1, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data fr

    Android中操作Sqlite遇到的错误:java.lang.IllegalStateException: Couldn't read row 1, col 0 from CursorWindow. ...

  9. java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

    在ViewPager中,用Fragment显示页面时,报错: java.lang.IllegalStateException: The specified child already has a pa ...

随机推荐

  1. 并没有看起来那么简单leetcode Generate Parentheses

    问题解法参考 它给出了这个问题的探讨. 超时的代码: 这个当n等于7时,已经要很长时间出结果了.这个算法的复杂度是O(n^2). #include<iostream> #include&l ...

  2. C++: 其他类型转string

    1.to_string函数 C++11新增的函数,c++11标准增加了全局函数std::to_string,以及std::stoi/stol/stoll等等函数(string转int,long,以及l ...

  3. fiddler抓包后Jmeter实现登录接口

    登录接口测试时,先要抓取登录接口,我们使用fiddler来抓包,如下图: 然后再使用Jmeter,填写相对于的参数. 查看结果树: 关键在与抓包,搞清楚抓包的信息,可以用fiddler和火狐和谷歌.我 ...

  4. ajax上传json串格式的数据的处理 以及 js操作dom的另一种方式

  5. Java框架之单元测试

    单元测试dao层 @Test   //1.要写 test public void TestUserDao(){ ApplicationContext ctx=new ClassPathXmlAppli ...

  6. 树状数组 二维偏序【洛谷P3431】 [POI2005]AUT-The Bus

    P3431 [POI2005]AUT-The Bus Byte City 的街道形成了一个标准的棋盘网络 – 他们要么是北南走向要么就是西东走向. 北南走向的路口从 1 到 n编号, 西东走向的路从1 ...

  7. luogu3704 [SDOI2017]数字表格(莫比乌斯反演)

    link 设\(f_0=0,f_1=1,f_n=f_{n-1}+f_{n-2}(n\ge 2)\) 求\(\prod_{i=1}^n\prod_{j=1}^mf_{\gcd(i,j)}\),多组询问, ...

  8. PAT天梯赛L1-054 福到了

    题目链接:点击打开链接 "福"字倒着贴,寓意"福到".不论到底算不算民俗,本题且请你编写程序,把各种汉字倒过来输出.这里要处理的每个汉字是由一个 N x N 的 ...

  9. mybatis和jdbc分析

    从这个图上可以看出mybatis的整体执行图 jdbc的 mybatis对很多类型进行了转化,减少了开发的量

  10. Ruby truthy and falsey

    在Ruby里只有false 和nil表示falsey link: https://gist.github.com/jfarmer/2647362