java: nullpointerexception can't solve

Penfound

Active Member
Licensed User
Longtime User
Hi guys - yes I have checked out other responses to this one but I still can't find it. The header panel appears at the top of the scroll view but nothing get added to it because it throws the error...

Sub SetHeader(Values() As String)
scvLibrary.Initialize(1000dip)
'Set the headers values
If pnlHeader.IsInitialized Then 'should only be called once
Return
End If
pnlHeader.Initialize("")
pnlHeader.Color = HeaderLineColor

For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("Header")
If SortDirection(i) = "ASC" Then
l.Text = Values(i) & " ↓"
Else
l.Text = Values(i) & " ↑"
End If
l.Text = Values(i)
l.Gravity = Gravity.CENTER
l.TextSize = FontSize
l.Color = HeaderColor
l.TextColor = HeaderFontColor
l.Tag = i
pnlHeader.AddView(l, TotalColumnWidth(i), 0, ColumnWidth_1(i), RowHeight_1)
Next
Activity.AddView(pnlHeader, scvLibrary.Left, 0, scvLibrary.Width, RowHeight)

End Sub

I know it is something simple but I just don't see it - can you please?
 

klaus

Expert
Licensed User
Longtime User
You initialize the scvLibrary ScrollView at the beginning of the SetHeader routine.
But you don't add it to the Activity, so when you make reference to it in scvLibrary.Left there will be an error because the ScrollView is not yet defined.
Do you add scvLibrary somewhere else to the Activity in your project ?

Unfortunately without seeing the complete code it's difficult to give you a concrete answer.
The best way to get a get an answer is to post the project as a zip file or at leat a smaller project showing the error. Too often the problem is not only in the code snippet you post but somewhere else.

Best regards.
 
Upvote 0

Penfound

Active Member
Licensed User
Longtime User
Ok, I added the scvLibrary and that got rid of the java error thanks - now I have a new problem that I shall post under a different heading.

Many thanks
 
Upvote 0
Top