I am trying to change the values being displayed in a listview depending on the value from a seekbar. Currently the listview is being populated by a cursor (whos values I dont think i can change once in the list). I am trying to added the cursor into an ArrayList before being added to the list.
My thinking is that I can change the array list elements and in turn update the listview. I am running into issues with creating the array list and then altering it to update the list view.
Example The listview contains 2 columns (name and value), these are what are being returned to the cursor and added into the arrayList. When the seekbar is on value (eg 2), all the value in the arrayList will be multiplied by 2. They are only to be updated in the list and not the database.
Can anyone help push me in the right direction to fix my arrayList and applying the seekbar changes
Cursor and ArrayList
final Cursor ings = adapter.getIngs(Code);
ingredients.moveToFirst();
ArrayList<String> IngsList = new ArrayList<String>();
while(!ings.isAfterLast())
{
Ings.add(ings.getString(ings.getColumnIndex("name")));
Ings.add(ings.getInt(ings.getColumnIndex("measurement")));
Ings.add(ings.getString(ings.getColumnIndex("unit")));
}
ings.close();
String[] columns = new String[] {adapter.KEY_NAME, adapter.KEY_MEASUREMENT, adapter.KEY_UNIT};
int[] to = new int[] {R.id.Name, R.id.Measurement, R.id.Unit};
final SimpleCursorAdapter Adpater = new SimpleCursorAdapter(this,R.layout.row5, ingredients, ingredient_columns, to, 0);
ListView Required = (ListView) findViewById(R.id.Required);
Required.setAdapter(Adpater);
SeekBar
seekBar = (SeekBar) findViewById(R.id.servingSeek);
textView = (TextView) findViewById(R.id.actualServing);
// Initialize the textview with '0'
textView.setText("Serving Size:" + seekBar.getProgress());
seekBar.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
int progress = 0;
@Override
public void onProgressChanged(SeekBar seekBar,
int progresValue, boolean fromUser) {
progress = progresValue;
textView.setText("Serving Size:" + progress);
//alter cursor values
//update cursor
}