Android Question MpAndroidChart NullPointerException in CLV


Active Member
Licensed User
Longtime User
I implemented successfully the MpAndroidChart library as the examples describes. Now I want to move the charts to a CLV so I can show a variable amount of charts depending on the user preference.

My first approach to this was to create the CLV in the designer and the item that will be added, in this case a chart.(Both created in the designer). The I add the item like this:
Sub CreateListItemChart(text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.SetLayout(0, 0, Width, Height)
    Return p
End Sub
Then plot the data.
For i=0 To clv.Size-1
   Dim panel As Panel = clv.GetPanel(i)
   Dim mlc As CombinedChart = panel.GetView(0)     
But here I get a null pointer exception.
If instead of getting each panel and getting the chart view as described above, I generate the variable with the designer name like this: (With only one item on the CLV)
Sub Globals
  Private mlc2 As CombinedChart
End Sub

I don't get the null pointer exception, but I don`t have the ability to choose the chart item from the list.

Looking in the source code of the library, I think that the CombinedChart variable "cv" is no being initialized but even if I initialize it I get the same error.

It only seems to work if I set variable in the global sub and use the same name of variable that the view name added in the designer.

Have someone been able to successfully add charts to CLV?


Licensed User
Longtime User
Upvote 0