Home > Back-end >  Error : Cannot convert from 'System.Collections.Generic.List<string>' to 'int&#
Error : Cannot convert from 'System.Collections.Generic.List<string>' to 'int&#

Time:09-21

Android.App.AlertDialog.Builder abc = new AlertDialog.Builder(this.Activity);
            abc.SetTitle(Resources.GetString(Resource.String.xyz));
            abc.SetCancelable(false);           
            abc.SetPositiveButton(GetString(Resource.String.OK), (s, args) => { });
            ArrayAdapter arrayAdapter = new ArrayAdapter<string>(this.Activity, Android.Resource.Layout.row_listview_layout, list);
            abc.SetAdapter(arrayAdapter, customDialogClickEventArgs);            
            abc.Create();
            abc.Show();

In this below line when i am passing the list it is showing error that : Cannot convert from 'System.Collections.Generic.List' to 'int'

ArrayAdapter arrayAdapter = new ArrayAdapter(this.Activity, Android.Resource.Layout.row_listview_layout, list);

CodePudding user response:

The Code is working fine after replacing the layout file From:

ArrayAdapter arrayAdapter = new ArrayAdapter<string>(this.Activity, Android.Resource.Layout.row_listview_layout, list);

To :

ArrayAdapter arrayAdapter = new ArrayAdapter<string>(this.Activity, Android.Resource.Layout.SimpleListItem1, list);
  • Related