У меня есть следующий макет:
Приведенный ниже код программно добавляет флажок в макет listlayout:
for (int i=0; i < MyParticipants.Tables[0].Rows.Count; i++)
{
feature1 = new CheckBox(this);
feature1.Text = MyParticipants.Tables[0].Rows["name"].ToString();
feature1.Id = Convert.ToInt32(MyParticipants.Tables[0].Rows["employeeid"].ToString());
feature1.CheckedChange += CheckBox_CheckedChange;
list.AddView(feature1);
}
Этот конкретный код является устаревшим, используется уже около 2 лет и работает нормально. Я пытался добавить счетчик справа от флажка, но не смог его правильно разместить. Есть идеи? Моя последняя попытка:
List itemsNew = new List();
itemsNew.Add("Select Program");
foreach (DataRow MyDataRow in MyProgramDataset.Tables[0].Rows)
{
if (!MyDataRow["Program"].ToString().ToUpper().Contains("FLAG"))
{
itemsNew.Add(MyDataRow["Program"].ToString());
}
};
for (int i=0; i < MyParticipants.Tables[0].Rows.Count; i++)
{
feature1 = new CheckBox(this);
feature1.Text = MyParticipants.Tables[0].Rows["name"].ToString();
feature1.Id = Convert.ToInt32(MyParticipants.Tables[0].Rows["employeeid"].ToString());
feature1.CheckedChange += CheckBox_CheckedChange;
feature2 = new Spinner(this);
// So I can identify which spinner belongs to which participant
feature2.Id = Convert.ToInt32(MyParticipants.Tables[0].Rows["employeeid"].ToString());
ArrayAdapter adapter = new ArrayAdapter(this, Resource.Layout.spinner_text_attr, itemsNew.ToArray());
feature2.Adapter = adapter;
list.AddView(feature1);
// I need to place the spinner to the right of the checkbox
list.AddView(feature2);
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... -on-layout