Trying to Implement a Listview control inside a ListView, Getting Exception

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.ListViewAdapter from native handle 0xbe9b85ac (key_handle 0x1cce8f2). while scrolling the Listview

Tagged:

Answers

  • sdithoneysdithoney Member ✭✭

    Please reply if anybody know the answer

  • FabricioBertaniFabricioBertani USMember ✭✭

    Provide a sample of the code you're using, only with an error msg we can't do anything.

  • sdithoneysdithoney Member ✭✭

    Here is the Outer Listview Code and XAML

    Code--

        public MainPage()
        {
            InitializeComponent();
            BindingContext = this;
            Persons = new ObservableCollection<Person>();
    
            DataArrayListView.ItemsSource = Persons;
    
            IList<Contact> Contacts = new List<Contact>();
    
            for (int i = 0; i < 5; i++)
                Contacts.Add(new Contact() { PhoneNumber = "+91 971833819"+i });
    
            for (int i = 0; i < 1055; i++)
                Persons.Add(new Person() {
                FullName = "Honey Kumar "+i,
                ContactDetail = Contacts,
                Number = "9718338194"
            });
    
        }
    

    XAML--


    <ListView.ItemTemplate>

                    <ViewCell>
    
                            <StackLayout Orientation="Vertical">
                                <Label Text="{Binding FullName}" Font="18" TextColor="Black"/>
                                <local:LocalList ArrayValue="{Binding ContactDetail, Mode = TwoWay}" />
    
                        </StackLayout>
                    </ViewCell>
    
                </DataTemplate>
            </ListView.ItemTemplate>
    
        </ListView>
    

    LocalList Code --

    public static readonly BindableProperty ArrayValueProperty = BindableProperty.Create(
    propertyName: "ArrayValue",
    returnType: typeof(System.Collections.IEnumerable),
    declaringType: typeof(LocalList),
    defaultValue: "",
    defaultBindingMode: BindingMode.TwoWay,
    propertyChanged: DataChanged);

        private static void DataChanged(BindableObject bindable, object oldValue, object newValue)
        {
            List<Contact> Items = new List<Contact>();
            //  var control = (LocalList)bindable;
            //  Name =newValue.ToString();
            //  Instance.DataText.Text = Name;
    
            var picker = bindable as LocalList;
    
            if ((List<Contact>)newValue != null)
            {
                //now it works like "subscribe once" but you can improve
                foreach (var item in (List<Contact>)newValue)
                {
                    Contacts.Add(item);
                }
            }
    
        }
    
        public LocalList ()
        {
    
            InitializeComponent ();
            Contacts = new ObservableCollection<Contact>();
            Instance = this;
            Name = "Honey";
            Content.BindingContext = this;
            ContactList.ItemsSource = Contacts;
    
        }
    

    LocalList XAML--


    <ListView.ItemTemplate>

                        <ViewCell>
                                    <Label Text="{Binding PhoneNumber}" Font="18" TextColor="Black"/>
    
                    </ViewCell>
    
                    </DataTemplate>
                </ListView.ItemTemplate>
    
            </ListView>
    
  • sdithoneysdithoney Member ✭✭

    Hi All, FFinally I came up with this solution after using a custom grid control view inside a listview. In the listview I pass the array to the custom class where passed data is processed for each loop

Sign In or Register to comment.