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

标题: [教学] 旋转荧幕就错误 Unable to instantiate fragment [打印本页]

作者: 资讯王    时间: 2012-12-25 13:26
标题: [教学] 旋转荧幕就错误 Unable to instantiate fragment
旋转荧幕就错误 - 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. }
复制代码





欢迎光临 大马资讯论坛 - 马来西亚中文资讯平台 (http://www.freeinfo.com.my/) Powered by Discuz! X3.3