Forum Xamarin.Android

TextInputEditText Object reference not set to an instance of an object

I would like to store in a string variable the input of a user after i show him a custom dialog.

public string titleInput;

    void ShowCustomDialog()
        string eventTitleDialog = Resources.GetText(Resource.String.eventTitleCustomDialog);

        View view = LayoutInflater.Inflate(Resource.Layout.custom_alertDialog, null);
        Android.Support.V7.App.AlertDialog builder = new Android.Support.V7.App.AlertDialog.Builder(this, Resource.Style.Base_Theme_AppCompat_Light_Dialog_Alert).Create();
        TextInputEditText editInputView = FindViewById<TextInputEditText>(Resource.Id.title_edittext);
        Button button = view.FindViewById<Button>(Resource.Id.btnOK);
        button.Click += delegate {

            titleInput = editInputView.Text;



but i always have an error at:

titleInput = editInputView.Text;
System.NullReferenceException: Object reference not set to an instance of an object.

I try

  if (editInputView == null) 
  editInputView.Error = GetString(Resource.String.editTextEmpty);

and I also change the way i initialize my TextInputEditText with this:

editInputView = builder.FindViewById<TextInputEditText>(Resource.Id.title_ed‌​ittext);

but i still the same error.

Any help?


  • Hi @SamihELSAKHAWI , I am facing this same issue. Did you manage to find a solution to this?

  • thisguyisbtbwthisguyisbtbw Member ✭✭
    edited February 2019

    @YkshLeo any suggestions? (looked at one of your EditText answers on the forum - thought you might be able to help?)

    The error I am facing is that -

    TextInputEditText passwordb = FindViewById< TextInputEditText >(Resource.Id.registername);
    string name = nameb.Text;

    using these lines of code doesn't help me get the input text.

    TIA :smile:

Sign In or Register to comment.