WindowManagerBadTokenException error calling ShowDropDown() on custom AutoCompleteTextView

pingpong.6106pingpong.6106 USMember ✭✭
edited August 2018 in Xamarin.Android

I want to display automicately a list on AutoCompleteTextView when an activitity is displayed without typing or clicking. However, the error belows occurs:

Android.Views.WindowManagerBadTokenException: Unable to add window -- token null is not valid; is your activity running? occurred

Below is the code:

 public class MyActivity : AppCompatActivity{
   protected override void OnResume()
        {
            base.OnResume();
            autoCompleteTextView.ShowDropDown();
        }
}


 public class MyAutoCompleteTextView: AutoCompleteTextView
    {
        public MyAutoCompleteTextView(Context context, IAttributeSet attrs)
           : base(context, attrs)
        {
        }

        public override bool EnoughToFilter()
        {
            return true;
        }      
    }

Best Answer

Answers

Sign In or Register to comment.