Answered step by step
Verified Expert Solution
Question
1 Approved Answer
private void showChoosePackage() { AlertDialog.Builder builder = new AlertDialog.Builder(descriptionsActivity.this); LayoutInflater inflater = this.getLayoutInflater(); View choose_package_layout = inflater.inflate(R.layout. choose_package_layout , null); builder.setView(choose_package_layout); final AlertDialog dialog =
private void showChoosePackage()
{ AlertDialog.Builder builder = new AlertDialog.Builder(descriptionsActivity.this); LayoutInflater inflater = this.getLayoutInflater(); View choose_package_layout = inflater.inflate(R.layout.choose_package_layout, null); builder.setView(choose_package_layout); final AlertDialog dialog = builder.create(); radioGroup = findViewById(R.id.radio_grp); Button btnApply = choose_package_layout.findViewById(R.id.button_apply); final RadioButton rdibtn = (RadioButton)choose_package_layout.findViewById(R.id.radio1); final RadioButton rdibtn2 = (RadioButton)choose_package_layout.findViewById(R.id.radio2); rdibtn.setText(Common.longhousedesc.PackageOne); rdibtn2.setText(Common.longhousedesc.PackageTwo); btnApply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int Selectedid = radioGroup.getCheckedRadioButtonId(); radioButton = findViewById(Selectedid); showConfirmDialog(radioButton.getText()); } }); builder.show(); }
my logcat is showing an error:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.RadioGroup.getCheckedRadioButtonId()' on a null object reference
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started