Reputation: 3686
This question isn't specific to the MPAndroidChart lib, but I'm expanding on the MPAndroidChart example app's ListViewMultiChartActivity
ChartDataAdapter
, and it abstracts out the RowItems (ChartItem
s in this case). Now, I'm used to holding all of my logic in the ArrayAdapter's getView()
, but in this case, it seems to be abstracted out into their own classes. My problem is being able to update the ChartItem
from within the different ChartItem
s..
Should I be passing through a copy of the ArrayAdapter
, or the ArrayList<ChartItem>
, into my different ChartItem
getViews()
? I have no issue holding and passing the reference/position in my chart's tag, but I still don't know how to update that single row in the list and update the adapter FROM the ChartItem itself.
I've tried different methods.. I've tried abstracting out getItem()
into each ChartItem
, but I don't think I understand Java abstraction enough to get what's going on here. I've tried referencing the ChartItem
as this
in each ChartItem
, and while I can update the row, it updates every other row of the same ChartItem
type..
I'm sure it's something simple I'm not wrapping my head around.. I think it has to do with the abstraction and not fully understanding what's happening there. I'd rather not move all of my ChartItem getView logic into my ArrayAdapter. I can't seem to find one other example where the RowItems/ChartItems are abstracted out like this.. at least not with updates to the list. Thanks.
EDIT
I've been messing with the ChartData<cd>
that's being passed into my LineChartItem
, and I can successfully modify datasets and have the change persists against re-draws of the list.. and then I'm calling chart.invalidate()
and cd.notifyDataSetChanged()
.. but my changes don't persist on rotation..
Upvotes: 1
Views: 95
Reputation: 3686
I finally figured out how to save the ChartItem
s ChartData<?>
for anyone else in the same boat.. I made my ChartItem
implement Parcleable
and then flattened the ChartData array into a Json string based on this answer. Works like a charm..
Upvotes: 1