public class ExpAdapter : BaseExpandableListAdapter
{
private int seed = 1000;
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = (LayoutInflater) context.GetSystemService(Context.LayoutInflaterService);
convertView = inflater.Inflate(Resource.Layout.inspection_row_2, null);
}
int currentID;
Random randomizer = new Random(seed);
TextView question = (TextView) convertView.FindViewById(Resource.Id.questionText);
RadioGroup radio = (RadioGroup) convertView.FindViewWithTag("actionGroup");
currentID = randomizer.Next(1,101);
radio.Id = currentID;
RadioButton pass = (RadioButton) convertView.FindViewWithTag("passed");
currentID = randomizer.Next(1,101);
pass.Id = currentID;
RadioButton fail = (RadioButton) convertView.FindViewWithTag("failed");
currentID = randomizer.Next(1,101);
fail.Id = currentID;
RadioButton correct = (RadioButton)convertView.FindViewWithTag("corrected");
currentID = randomizer.Next(1,101);
correct.Id = currentID;
RadioButton na = (RadioButton)convertView.FindViewWithTag("na");
currentID = randomizer.Next(1,101);
na.Id = currentID;
string[][] items = questions.childItems();
question.Text = items[groupPosition][childPosition];
seed++;
return convertView;
}
}
Using a breakpoint to step through the above, currentID = 1 throughout execution. The above method gets called repeatedly as MonoDroid creates the child group of controls under the parent group and currentID is ALWAYS = 1. I have also tried creating currentID and randomizer as private static variables within the entire class. Same result.
EDIT: I attempted to create the new Random instances with a seed value that differed for each call to GetChildView. Code is edited above to show how I did that. Still the value of currentID is always = 1. Below is screen shot of information for randomizer in Locals. This information looks the same regardless of what the seed number is. ???

Randomizer is calculated with system time in milliseconds. So, if you call it rapidly, ie in same millisecond, they get seeded with same number, thus resulting in same random number.