find other solutions on the Internet
error log:
java.lang.NullPointerException: Attempt to invoke virtual method "android.view.View android.app.Activity.findViewById (int)" on a null object reference at com.dmxy.fragment.ChannelFragment.onCheckedChanged (ChannelFragment.java:226)
Code:
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (json != null) {
Gson gson = new Gson();
ChannelGameTypeBean channelGameTypeBean = gson.fromJson(json, ChannelGameTypeBean.class);
List<ChannelGameTypeBean.DataBean> data = channelGameTypeBean.getData();
//TODO:
ChannelGameTypeBean.DataBean dataBean = data.get(0);// 1. 2. 3.
List<ChannelGameTypeBean.DataBean.NavBean> nav = dataBean.getNav();
ChannelGameTypeBean.DataBean.NavBean navBean = nav.get(checkedId);//0. 1. 2. 3. 4.
int navId = navBean.getNavid();
int sizes = data.size();
String size = String.valueOf(sizes);
//POST
BaseApplication.getApplication().getMap().put("navId", navId);
BaseApplication.getApplication().getMap().put("size", size);
}
// TODO
//TODO:bug
RadioButton tempButton = getActivity().findViewById(checkedId); //
Log.d(TAG, "2222222222222");
tempButton.setOnClickListener(this);
}