亲测笔记,主动抛出错误,android开发,亲测笔记,try..catch, throw new RuntimeException

石头 2016-11-28 16:31:33

主动抛出错误

if (context instanceof OnListFragmentInteractionListener) {
mListener = (OnListFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnListFragmentInteractionListener");
}