Exception in RadioButton Click Event AlertDialog.Builder Popup

KathirVelKathirVel USMember ✭✭

In our Xamarin Android application, We have the following scenario.

  • Register a New call request with "Add Feedback" option.
  • By clicking the Add Feedback , AlertDialog.Builder opened as pop up by LayoutInflater.
  • The Popup layout contains Radio button controls for user selection. By tapping on the radio button, we need to fire the OnClick Event
  • But the OnClick event is not fired up and shows the below error.

Error Message:
java.lang.IllegalStateException: Could not find a method onRadioButtonClicked_responsetime(View) in the activity class mono.android.app.Application for onClick handler on view class android.widget.RadioButton with id 'rb_feeback_responsetime_Excellent'

Kindly help me to resolve the issue for firing up Radio Button Click Events.

Open PopUp Function:
void ShowFeedbackPopUp() { _GlobalFunctionsClass.CloseKeyPad(this); builder = new AlertDialog.Builder(this, Android.Resource.Style.ThemeTranslucentNoTitleBar); inflater = LayoutInflater.From(ApplicationContext); alertView = inflater.Inflate(Resource.Layout.HelpDeskViewFeedback, null); builder.SetTitle("Feedback"); builder.SetView(alertView); rb_feeback_responsetime_Excellent = alertView.FindViewById<RadioButton>(Resource.Id.rb_feeback_responsetime_Excellent); rb_feeback_responsetime_Good = alertView.FindViewById<RadioButton>(Resource.Id.rb_feeback_responsetime_Good); rb_feeback_responsetime_Avg = alertView.FindViewById<RadioButton>(Resource.Id.rb_feeback_responsetime_Avg); rb_feeback_responsetime_Poor = alertView.FindViewById<RadioButton>(Resource.Id.rb_feeback_responsetime_Poor); //And required Control Intializations }

Radio Button Click Events:
[Java.Interop.Export("onRadioButtonClicked_responsetime")] public void onRadioButtonClicked_responsetime(View view) { try { // Is the button now checked? bool check = ((RadioButton)alertView).Checked; // Check which radio button was clicked switch (alertView.Id) { case Resource.Id.rb_feeback_responsetime_Excellent: break; case Resource.Id.rb_feeback_responsetime_Good: break; } } catch (Exception ex) { } }

Designer:
<LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"> <RadioButton android:id="@+id/rb_feeback_responsetime_Excellent" style="@style/RadioButtonContentStyle" android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:onClick="onRadioButtonClicked_responsetime" android:text="@string/HDS_Excellent" /> </LinearLayout> <LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"> <RadioButton android:id="@+id/rb_feeback_responsetime_Good" android:text="@string/HDS_Good" style="@style/RadioButtonContentStyle" android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:onClick="onRadioButtonClicked_responsetime" android:paddingLeft="30dp" /> </LinearLayout> </LinearLayout>

Tagged:
Sign In or Register to comment.