This is after updating the item in another activity and returning a result. The code for attempting to update the listview item is in the below onActivityResult text. What I want to do (but can't find help on) is to simply update the original data source and then update the listview item directly. I'm starting to think this isn't possible. As a matter of fact, if I scroll down to a listview item that's below and try to edit it, the proper data is passed on to the activity called, but the item is never updated in the listview at all. Guessing the listview doesn't call the actual item that I edited.
The listview and adapter work perfectly when starting it all up. Scrolling and all are great. It's after I try to update an item that things go south.
To repeat myself.
1. Click on item is listview
2. Edit the data in the activity called (for result)
3. Update my original data used to populate the listview
4. Update what's displayed in the listview to reflect my changes
The third item in the list below is fine until it's scrolled off the screen. Tried this with a holder-arrayAdapter and then with a standard arrayAdapter,
Still stuck on windows listviews so this is rather new to me how the adapters work.
I also have tried notifying the adapter of changes but I've read that that only works if you insert or delete from the original data.
at this point I'd settle for clearing the listview and loading the data again. setting arrayAdapter is suppose to be a bad thing to do, I hear. Lots more open help out there when I was a windows programmer.
View attachment 157239
Java:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 501 && resultCode == RESULT_OK) {
DecimalFormat f = new DecimalFormat("000,000");
int locid = data.getIntExtra("locationid", 1);
int id = data.getIntExtra("id", -1);
int pos = data.getIntExtra("position", -1);
int mil = data.getIntExtra("mileage", 0);
double cos = data.getDoubleExtra("cost", 0);
String typ = data.getStringExtra("type");
String tit = data.getStringExtra("title");
String des = data.getStringExtra("description");
String dat = data.getStringExtra("date");
ImageView icon = (ImageView) v.findViewById(R.id.rowIcon);
TextView cat = (TextView) v.findViewById(R.id.rowCategory);
TextView desc = (TextView) v.findViewById(R.id.rowDescription);
TextView mileage = (TextView) v.findViewById(R.id.rowMileage);
TextView date = (TextView) v.findViewById(R.id.rowDate);
TextView cost = (TextView) v.findViewById(R.id.rowCost);
TextView loc = (TextView) v.findViewById(R.id.rowLocation);
LocalDateTime lt = convert.DateTimeFromString(dat);
icon.setImageResource(getIconIndex(typ));
cat.setText(typ);
items[ItemPosition].setCategory(typ);
desc.setText(des);
items[ItemPosition].setDescription(des);
date.setText(dat);
items[ItemPosition].setEntryDate(dat);
mileage.setText(f.format(mil));
items[ItemPosition].setMileage(mil);
date.setText(convert.DateAndTimeValuesAsString(lt));
items[ItemPosition].setEntryDate(dat);
loc.setText(String.valueOf(locid));
items[ItemPosition].setLocationID(1);
cost.setText(convert.CurrencyAsText(cos));
items[ItemPosition].setCost(cos);
}
}