Forum Xamarin.Android

Dynamical custom listview

I need to create dynamical custom listview.
First my step is create a listview manually :
public override View GetView(int position, View convertView, ViewGroup parent) { var item = items[position]; View view = convertView; if (view == null) // no view to re-use, create new { var layout = new RelativeLayout(context); LinearLayout scrollView = new LinearLayout(context,null,10); scrollView.Orientation = Android.Widget.Orientation.Horizontal; TextView txt = new TextView(context); txt.Text = "Random text"; CheckBox chk = new CheckBox(context); chk.Checked = true; chk.Text = ""; scrollView.AddView(txt); scrollView.AddView(chk); layout.AddView(scrollView); view = layout; } return view; }
and it work nice:
But how can i change weight(not width!) and height of RelativeLayout/LinearLayout, CheckBox / TextView ?
'chk.Height = 100'
'var param = layout.LayoutParameters;
param.Height = 100;'
is not work for me or i something do wrong?


  • CasperSrensenCasperSrensen DKMember

    Did you call "layout.RequestLayout()" after changing the LayoutParameters? You need to do that to update the layout if I remember correctly.

Sign In or Register to comment.