I have created a customListView with two labels and an editText View. The List is populated from a remote mysql database. I am also able to edit data in the edit text view. Now I am trying to save the data in the mysql database. two things take place:
1. If I scroll the list and then save the data it saves the data perfectly.
2. If I do not scroll and try to save the data; there is an error " java.lang.RuntimeException: Object should first be initialized (View)." why this behaviour? can any one explain . The code I am using is as below: errror is showing in line 29 below. The xCustomListView in from the designer.
1. If I scroll the list and then save the data it saves the data perfectly.
2. If I do not scroll and try to save the data; there is an error " java.lang.RuntimeException: Object should first be initialized (View)." why this behaviour? can any one explain . The code I am using is as below: errror is showing in line 29 below. The xCustomListView in from the designer.
B4X:
Sub CLV_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
clvchange=True
Dim ExtraSize As Int = 25 'List size
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CLV.Size - 1)
Dim pnl As B4XView = CLV.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
If pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
Dim ID As studentData = CLV.GetValue(i)
pnl.LoadLayout("frmschoinfo")
LblRno.Text = ID.rno
LblStudent.Text = ID.sname
edtMark.Text = ID.mark
End If
Else 'Not visible
If pnl.NumberOfViews > 0 Then
pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
End If
End If
Next
End Sub
Sub btnSave_Click
'save data to database
For j=0 To CLV.size -1
dmap.Initialize
dmap.Put("roll",CLV.GetPanel(j).GetView(0).text)
dmap.Put("mark",CLV.GetPanel(j).GetView(2).text)
data.Add(dmap)
Next
Wait For(AddMark ) Complete( ResStatus As String )
If ResStatus.trim<>"" Then
ToastMessageShow(ResStatus,True)
Else
ToastMessageShow("No Changes",True)
End If
End Sub