Yes, your sample runs without a problem indeed. But I now see what the difference is: you have only text, but I have both, text and images.
I explicitly build each Picker entry (row) in code as follows (m_pics is a string list containing all the images names and m_strings is a string list that contains all the text entries - current image is m_pics[row] and current row text is m_strings[row]):
void LoadPickerView(int row)
{
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent
);
layoutParams.Height = (int)m_picker.ItemHeight;
layoutParams.Width = (int)m_picker.Width;
LinearLayout rowView = new LinearLayout(m_context) { Orientation = Orientation.Vertical };
LinearLayout rowData = new LinearLayout(m_context);
rowData.Orientation = Orientation.Horizontal;
ImageView rowImage = null;
if (m_pics != null && m_pics.Count > row)
{
rowImage = new ImageView(m_context);
rowImage.SetImageResource(m_pics[row]);
AdjustPickerView(rowImage, row);
rowData.AddView(rowImage, ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
}
TextView rowText = null;
if (m_strings != null && m_strings.Count > row)
{
rowText = new TextView(m_context);
rowText.Text = " " + m_strings[row];
rowText.TextAlignment = m_alignment.Item2;
rowText.SetBackgroundColor(m_bgColor);
rowText.Gravity = GravityFlags.CenterVertical;
AdjustPickerView(rowText, row);
rowData.AddView(rowText, ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
}
ImageView line = new ImageView(m_context);
line.SetImageResource(m_linePic);
line.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
rowView.AddView(rowData, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
rowView.AddView(line, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
rowView.LayoutParameters = layoutParams;
m_imageViews.Add(rowImage);
m_textViews.Add(rowText);
m_pickerViews.Add(rowView);
}
Then I assign all these Views in the OnPickerItemLoaded event handler:
m_picker.OnPickerItemLoaded += (sender, e) =>
{
if (m_pics == null)
{
return;
}
LoadPickerViewsIfNeeded();
e.CustomView = m_pickerViews[e.Row];
};
So when I have no images (m_pics = null) all is fine. With Images it doesn't change the picker wheel on a programmatic select (but the entry is selected, just not visible).