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

 找回密码
 注册
搜索

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

[复制链接]
发表于 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, 2022-9-30 07:58 , Processed in 0.124725 second(s), 13 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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