如何将此自定义 ListView ArrayAdapter 连接在一起?
How can I wire together this Custom ListView ArrayAdapter?
此问题并非特定于 MPAndroidChart 库,但我正在扩展 MPAndroidChart 示例应用程序的 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..
我应该通过 ArrayAdapter
或 ArrayList<ChartItem>
的副本进入我的不同 ChartItem
getViews()
吗?我在我的图表标签中保存和传递 reference/position 没有问题,但我仍然不知道如何更新列表中的那一行并从 ChartItem 本身更新适配器。
我试过不同的方法..我试过将 getItem()
抽象到每个 ChartItem
中,但我认为我对 Java 抽象的理解还不足以得到什么在这里进行。我尝试在每个 ChartItem
中将 ChartItem
引用为 this
,虽然我可以更新该行,但它会更新相同 ChartItem
类型的每隔一行..
我确定这很简单,但我并没有绞尽脑汁。我认为这与抽象有关,并且没有完全理解那里发生的事情。我不想将我所有的 ChartItem getView 逻辑移到我的 ArrayAdapter 中。我似乎找不到另一个例子,其中 RowItems/ChartItems 是这样抽象出来的……至少没有更新列表。谢谢。
编辑
我一直在弄乱正在传递到我的 LineChartItem
中的 ChartData<cd>
,我可以成功修改数据集并使更改持续存在以防止重新绘制列表..然后我正在调用 chart.invalidate()
和 cd.notifyDataSetChanged()
.. 但我的更改不会持续旋转..
我终于想出了如何为同一条船上的其他人保存 ChartItem
s ChartData<?>
。我制作了我的 ChartItem
工具 Parcleable
然后压扁基于 this answer 将 ChartData 数组转换为 Json 字符串。工作起来很有魅力..
此问题并非特定于 MPAndroidChart 库,但我正在扩展 MPAndroidChart 示例应用程序的 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..
我应该通过 ArrayAdapter
或 ArrayList<ChartItem>
的副本进入我的不同 ChartItem
getViews()
吗?我在我的图表标签中保存和传递 reference/position 没有问题,但我仍然不知道如何更新列表中的那一行并从 ChartItem 本身更新适配器。
我试过不同的方法..我试过将 getItem()
抽象到每个 ChartItem
中,但我认为我对 Java 抽象的理解还不足以得到什么在这里进行。我尝试在每个 ChartItem
中将 ChartItem
引用为 this
,虽然我可以更新该行,但它会更新相同 ChartItem
类型的每隔一行..
我确定这很简单,但我并没有绞尽脑汁。我认为这与抽象有关,并且没有完全理解那里发生的事情。我不想将我所有的 ChartItem getView 逻辑移到我的 ArrayAdapter 中。我似乎找不到另一个例子,其中 RowItems/ChartItems 是这样抽象出来的……至少没有更新列表。谢谢。
编辑
我一直在弄乱正在传递到我的 LineChartItem
中的 ChartData<cd>
,我可以成功修改数据集并使更改持续存在以防止重新绘制列表..然后我正在调用 chart.invalidate()
和 cd.notifyDataSetChanged()
.. 但我的更改不会持续旋转..
我终于想出了如何为同一条船上的其他人保存 ChartItem
s ChartData<?>
。我制作了我的 ChartItem
工具 Parcleable
然后压扁基于 this answer 将 ChartData 数组转换为 Json 字符串。工作起来很有魅力..