大马资讯论坛 - 马来西亚中文资讯平台

 找回密码
 注册
搜索
打印 上一主题 下一主题

[教学] 旋转荧幕就错误 Unable to instantiate fragment

[复制链接]
跳转到指定楼层
1#
发表于 2012-12-25 13:26:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
旋转荧幕就错误 - Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.Tab2Fragment: make sure class name exists, is public, and has an empty constructor that is public

不管怎样,一定要有一个空的constructor,不然一定报错当旋转荧幕。
请参考如下:
  1. public class Tab2Fragment extends Fragment  {
  2.         private int iPage = 1;   

  3.         public Tab2Fragment(){}
  4.        
  5.         public Tab2Fragment(int xiPage){
  6.                 iPage = xiPage;
  7.         }
  8. }
复制代码

手机版|大马资讯论坛  

GMT+8, 2024-4-19 15:26 , Processed in 0.168727 second(s), 13 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表