프래그먼트에 라디오그룹이 있는데....
리스너가 먹히질 않어요,,
@SuppressLint("ValidFragment")
public class tap3_View extends Fragment {
Context mContext;
ImageView location1, bluetooth1, user1, alarm1, deviceloc1, sensor1, off1, push1;
RadioButton option1, option2;
RadioGroup radioGroup;
public tap3_View(Context context) {
mContext = context;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.v("TAP-3-VIEW", "create success!!");
View view = inflater.inflate(R.layout.fragment_tap3__view, null);
location1 = (ImageView)view.findViewById(R.id.image1);
location1.setImageResource(R.mipmap.location1);
bluetooth1 = (ImageView)view.findViewById(R.id.image2);
bluetooth1.setImageResource(R.mipmap.bluetooth1);
user1 = (ImageView)view.findViewById(R.id.image3);
user1.setImageResource(R.mipmap.user1);
alarm1 = (ImageView)view.findViewById(R.id.image4);
alarm1.setImageResource(R.mipmap.alarm1);
deviceloc1 = (ImageView)view.findViewById(R.id.image5);
deviceloc1.setImageResource(R.mipmap.location1);
sensor1 = (ImageView)view.findViewById(R.id.image10);
sensor1.setImageResource(R.mipmap.sensor);
off1 = (ImageView)view.findViewById(R.id.image11);
off1.setImageResource(R.mipmap.alarmoff);
push1 = (ImageView)view.findViewById(R.id.image12);
push1.setImageResource(R.mipmap.push);
radioGroup = (RadioGroup)getActivity().findViewById(R.id.radiogroup);
option1 = (RadioButton)getActivity().findViewById(R.id.option1);
option2 = (RadioButton)getActivity().findViewById(R.id.option2);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId){
// Your code
case 0:
Toast.makeText(getActivity(),"차량용 선택하셨습니다", Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(getActivity(),"가정용 선택하셨습니다", Toast.LENGTH_SHORT).show();
break;
}
}
});
//getActivity();
//Toast.makeText(getActivity()," tap 3 toast", Toast.LENGTH_SHORT).show();
return view;
}
}
로그캣 오류는 다음과 같습니다..
06-10 10:23:52.863 11499-11499/firstversion.v2.fdd.com.noticekorea.www.fdd_notice E/AndroidRuntime: FATAL EXCEPTION: main
Process: firstversion.v2.fdd.com.noticekorea.www.fdd_notice, PID: 11499
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RadioGroup.setOnCheckedChangeListener(android.widget.RadioGroup$OnCheckedChangeListener)' on a null object reference
at