Hi everyone,
I try to use the xCustomListView and add a different image in each item according to its functionality but I get an error.
Here is the code:
In the highlighted line I get the error:
What am I doing wrong? I am not familiar with the usage of xCustomListView...
P.S. The xCustomListView is located in a panel in order to be able to hide it and show it at will (No .visible property in xCustomListView)
I try to use the xCustomListView and add a different image in each item according to its functionality but I get an error.
Here is the code:
Addition of items to the xCustomListView:
Sub cmdComm_Click
clvComm.Clear
clvComm.Add(CreateCLVItem(sPhone1, "P"), "tel:" & sPhone1)
If sPhone2 <> "" Then clvComm.Add(CreateCLVItem(sPhone2, "P"), "tel:" & sPhone2)
If sEmail <> "" Then clvComm.Add(CreateCLVItem(sEmail, "E"), "mailto:" & sEmail)
pnlCLV.Visible = True
End Sub
Sub CreateCLVItem(sPhone As String, ComType As String) As B4XView
Dim clvi As Panel
clvi.Initialize("")
clvi.SetLayoutAnimated(0,0,0,100%x,50dip)
clvi.LoadLayout("CommCLV")
lblPhone.Text = sPhone
Dim img As ImageView = cmdCommunicate
Select Case ComType
Case "P"
img.Bitmap = LoadBitmap(File.DirAssets,"phone-icon.png")
Case "E"
img.Bitmap = LoadBitmap(File.DirAssets,"mail-icon.png")
End Select
Return clvi
End Sub
In the highlighted line I get the error:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.ColorStateList.getDefaultColor()' on a null object reference
at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(B4XViewWrapper.java:399)
at b4a.example3.customlistview._insertatimpl(customlistview.java:556)
at b4a.example3.customlistview._insertat(customlistview.java:538)
at b4a.example3.customlistview._add(customlistview.java:71)
at dhqi.trial.comm._cmdcallhotel_click(hotel.java:497)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7341)
at android.widget.TextView.performClick(TextView.java:14162)
at android.view.View.performClickInternal(View.java:7307)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27796)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(B4XViewWrapper.java:399)
at b4a.example3.customlistview._insertatimpl(customlistview.java:556)
at b4a.example3.customlistview._insertat(customlistview.java:538)
at b4a.example3.customlistview._add(customlistview.java:71)
at dhqi.trial.comm._cmdcallhotel_click(hotel.java:497)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7341)
at android.widget.TextView.performClick(TextView.java:14162)
at android.view.View.performClickInternal(View.java:7307)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27796)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
What am I doing wrong? I am not familiar with the usage of xCustomListView...
P.S. The xCustomListView is located in a panel in order to be able to hide it and show it at will (No .visible property in xCustomListView)