报错信息如下:
android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ***.base.OlineFragment
: make sure class name exists, is public, and has an empty constructor that is public....
这个时候正确的方法是实例化。
public static OnlineFragment getInstance(int id) { OnlineFragment instance = new OnlineFragment(); Bundle args = new Bundle(); args.putInt("id", id); instance.setArguments(args); return instance; }在onCreateView的方法里面再取出来传进参数。
Bundle args = getArguments(); if (args != null) { id = args.getInt("id"); }