I suggest creating a simple mapping between TextView
id and Seekbar
id. This way each id will be different and you can still get the corresponding item id. Here is my solution:
mGuestCount = InBetweenUIAndBusinessLogic.getGuests();
for (int i = 0; i < InBetweenUIAndBusinessLogic.getGuests(); i++) {
View v = in.inflate(R.layout.row_per_person, table, false);
double tipPerIndividual = (Math.round(InBetweenUIAndBusinessLogic
.getTipPerPerson() * 100.0) / 100.0);
String tip = Double.toString(tipPerIndividual);
tipPerPerson = (TextView) v.findViewById(R.id.tipPerPerson);
tipPerPerson.setId(i);
tipPerPerson.setText(tip);
rows.add(tipPerPerson);
percentageTip = (SeekBar) v.findViewById(R.id.seekBar1);
percentageTip.setOnSeekBarChangeListener(new myListener());
double guests = InBetweenUIAndBusinessLogic.getGuests();
percentageTip.setProgress((int) (100 / guests));
percentageTip.setId(i + mGuestCount);
table.addView(v);
bars.add(percentageTip);
}
Now to find the textview:
public static void setNewTipAmount(SeekBar barChanged, double amountForTip) {
int getID = barChanged.getId(); //get seekbar id
TextView textView = tipPerPerson.findViewById(getID - mGuestCount);// get the textview with corresponding id
textView.setText("Hello");
}