protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.ListView> e)
        {
            base.OnElementChanged(e);

            global::Android.Widget.ListView native = Control as global::Android.Widget.ListView;
            ListViewEx newElement = e.NewElement as ListViewEx;

            if (native != null && newElement != null)
            {
                SetAdapter(native, newElement);
            }
        }
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            global::Android.Widget.ListView native = Control as global::Android.Widget.ListView;
            ListViewEx newElement = sender as ListViewEx;

            if (native != null && newElement != null)
            {
                if (e.PropertyName == "ItemsSource")
                {
                    SetAdapter(native, newElement);
                }
            }
        }
Beispiel #3
0
        public virtual void SetListView(global::Android.Widget.ListView p0)
        {
            if (id_setListView_Landroid_widget_ListView_ == IntPtr.Zero)
            {
                id_setListView_Landroid_widget_ListView_ = JNIEnv.GetMethodID(class_ref, "setListView", "(Landroid/widget/ListView;)V");
            }

            if (GetType() == ThresholdType)
            {
                JNIEnv.CallVoidMethod(Handle, id_setListView_Landroid_widget_ListView_, new JValue(p0));
            }
            else
            {
                JNIEnv.CallNonvirtualVoidMethod(Handle, ThresholdClass, JNIEnv.GetMethodID(ThresholdClass, "setListView", "(Landroid/widget/ListView;)V"), new JValue(p0));
            }
        }
        private void SetAdapter(global::Android.Widget.ListView native, ListViewEx newElement)
        {
            var adapterClassName    = newElement.ItemTemplateClassName;
            var adapterAssemblyName = newElement.ItemTemplateAssemblyName;

            List <Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith(adapterAssemblyName)).ToList();
            Assembly        assembly   = assemblies.FirstOrDefault(a => a.GetType(adapterClassName, false) != null);

            if (assembly == null)
            {
                throw new Exception("Invalid ItemTemplateAssemblyName");
            }

            var adapterType = assembly.GetType(adapterClassName);

            if (adapterType == null)
            {
                throw new Exception("Invalid ItemTemplateClassName");
            }

            if (adapterType.IsSubclassOf(typeof(IListAdapter)))
            {
                throw new Exception("ItemTemplateClassName must be a sub-class of ArrayAdapter");
            }

            try
            {
                var adapter = (IListAdapter)Activator.CreateInstance(adapterType, Context, newElement.ItemsSource);
                native.Adapter = adapter;
            }
            catch (TargetInvocationException)
            {
                throw new Exception("The adapter defined in ItemTemplateClassName must have a constructor with (Context context, IList<T> items) and it must handle when IList<T> items == null");
            }
            catch (MissingMethodException)
            {
                throw new Exception("The adapter defined in ItemTemplateClassName must have a constructor with (Context context, IList<T> items) and it must handle when IList<T> items == null");
            }
        }
 public CustomTableViewModelRenderer(Context Context, global::Android.Widget.ListView ListView, TableView View)
     : base(Context, ListView, View)
 {
 }
 public CustomHeaderTableViewModelRenderer(Context context, global::Android.Widget.ListView listView, TableView view) : base(context, listView, view)
 {
     _coloredTableView = view as ColoredTableView;
 }
 protected override TableViewModelRenderer GetModelRenderer(global::Android.Widget.ListView listView, TableView view)
 {
     return(new CustomHeaderTableViewModelRenderer(Context, listView, view));
 }
 public override void OnListItemClick(global::Android.Widget.ListView l, View v, int position, long id)
 {
     // Insert desired behavior here.
     Log.I(TAG, "Item clicked: " + id);
 }
 public CustomTableViewModelRenderer(Context context, global::Android.Widget.ListView listView, TableView view) : base(context, listView, view)
 {
     _resizedTableView = view as ResizedTableView;
 }
Beispiel #10
0
 static void n_SetListView_Landroid_widget_ListView_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0)
 {
     global::Com.Nhaarman.Listviewanimations.Itemmanipulation.AnimateAdditionAdapter __this = global::Java.Lang.Object.GetObject <global::Com.Nhaarman.Listviewanimations.Itemmanipulation.AnimateAdditionAdapter> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
     global::Android.Widget.ListView p0 = global::Java.Lang.Object.GetObject <global::Android.Widget.ListView> (native_p0, JniHandleOwnership.DoNotTransfer);
     __this.SetListView(p0);
 }