0
给定一个片段的新实例方法:PutLong对空长在参数捆绑
public static MyFragment newInstance(Long someLong) {
Bundle args = new Bundle();
MyFragment fragment = new WorkoutDetailsRoutineInfoFragment();
args.putLong(ARGS_LONG, someLong);
fragment.setArguments(args);
return fragment;
}
如果someLong
为空,这是行不通的。
产生的原因:显示java.lang.NullPointerException:尝试在空对象引用调用虚拟 法“长java.lang.Long.longValue()”
我如何得到它存储Long即使它是空的?
你为什么需要它?如果你不存储它,这将意味着它是空的 – Pein
因为有时它是空的,有时它不是 – user7085962