- /**
- * 需要使用不带参数的构造器,可以使用getActivity()替换context参数
- * 否则屏幕在旋转的时候会抛出异常:
- * Caused by: java.lang.InstantiationException:
- * can't instantiate class com.michael.fragment.FragmentExecute; no empty constructor
- *
- * @see http://stackoverflow.com/questions/7016632/unable-to-instantiate-fragment
- * */
public static final MyFragment newInstance(int title, String message)
{
MyFragment fragment = new MyFragment();
Bundle bundle = new Bundle(2);
bundle.putInt(EXTRA_TITLE, title);
bundle.putString(EXTRA_MESSAGE, message);
fragment.setArguments(bundle);
return fragment ;
}
@Override
public Dialog onCreate(Bundle savedInstanceState)
{
title = getArguments().getInt(EXTRA_TITLE);
message = getArguments().getString(EXTRA_MESSAGE);
//...
//etc
//...
}