public static void SetAdapter(this LinearLayout layout, BaseAdapter adapter)
 {
     layout.RemoveAllViews();
     for (int i = 0; i < adapter.Count; i++)
     {
         layout.AddView(adapter.GetView(i, null, layout));
     }
 }
 public static void SetAdapter(this LinearLayout layout, BaseAdapter adapter, int?dpPaddingTop = null)
 {
     //LinearLayout.LayoutParams param = null;
     //if (dpPaddingTop != null)
     //     param = new LinearLayout.LayoutParams(-1,-2) {TopMargin = DimensionsHelper.DpToPx(dpPaddingTop.Value)};
     layout.RemoveAllViews();
     for (int i = 0; i < adapter.Count; i++)
     {
         layout.AddView(adapter.GetView(i, null, layout));
     }
 }
Exemple #3
0
        /// <summary>
        /// properly sets the listview height
        /// </summary>
        /// <param name="listView"></param>
        public static void SetListViewHeightBasedOnChildren(this ListView listView)
        {
            BaseAdapter adapter = (BaseAdapter)listView.Adapter;

            if (adapter == null)
            {
                return;
            }

            int  height = 0;
            View view   = null;

            for (int i = 0; i < adapter.Count; i++)
            {
                view    = adapter.GetView(i, view, listView);
                height += view.MeasuredHeight;
            }

            ViewGroup.LayoutParams parameters = listView.LayoutParameters;
            parameters.Height         = height + ((listView.DividerHeight) * (adapter.Count - 1));
            listView.LayoutParameters = parameters;
            listView.RequestLayout();
        }
        //@Override
        //@NonNull
        //public View getView(int position, View convertView, ViewGroup parent) {
        //    return mDecoratedBaseAdapter.GetView(position, convertView, parent);
        //}

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            return(mDecoratedBaseAdapter.GetView(position, convertView, parent));
        }