Android Question Customer Listview on AS Tabstrip

Good day!

I am trying to incorporate the Customer Listview in the AS Tabstrip. I want to know what I'm doing wrong. Please see the code below.

#Region  Project Attributes 
    #ApplicationLabel: Tabs-List Example
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
End Sub

Sub Globals
    Private xui As XUI
    Private ASTabStrip1 As ASTabStrip
    Type ItemValue (Label1 As Label)
    Private clvCO As CustomListView
    Private lblOrderRef As Label
    Private OrderAmount As Label
    Private lblCustomer As Label
    Private lblCustContact As Label
    Private lblDelType As Label
    Private Label1 As Label
    Private Label2 As Label
    Private Label3 As Label
    Private lblStoreAdr As Label
    Dim ImageView1 As ImageView
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim image As List
    ASTabStrip1.AddTab("Current_Order", "Current Orders",Null,"")
    ASTabStrip1.AddTab("For_Delivery", "For Delivery", Null,"")
    ASTabStrip1.AddTab("Finished_Orders", "Finished Orders",Null,"")
    ASTabStrip1.AddTab("Order_History", "Order History",Null,"")
    For Each f As String In Array("govesmart.png")
        image.Add(LoadBitmapResize(File.DirAssets, f, 100dip, 100dip, True))
    For i = 1 To 20
        Dim iv As ItemValue
        clvCO.Add(CreateItem(image.Get(i Mod image.Size), iv), iv)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
End Sub

Private Sub CreateItem (img As Bitmap, iv As ItemValue) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 100%x, 120dip)
    ImageView1.Bitmap = img
    lblOrderRef.Text = "Reference No: 0235"
    OrderAmount.Text = "P 500"
    lblCustomer.Text = "Jon Caesar Basco"
    lblCustContact.Text = "09553174861"
    lblDelType.Text = "Express"
    lblStoreAdr.Text = " STORE ADDRESS: GoveSmart Solutions, Inc.m Luna Street, Lapaz, Iloilo City, Iloilo, Philippines"

    Return p
End Sub
End Sub

Also, below is the error that I am getting.

Logger connected to: HUAWEI STK-L22
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 89 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.objects.collections.List.getSize()' on a null object reference
at b4a.example3.customlistview._add(
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(
at TabsList.example.main.afterFirstLayout(
at TabsList.example.main.access$000(
at TabsList.example.main$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)
** Activity (main) Resume **
I'm not familiar with ASTabStrip but it looks like clvCO was not added to any of the layout files.
Yes, it is because clvCO is initialized in layout "Current_Order"

ASTabStrip1.AddTab("Current_Order", "Current Orders",Null,"")

Which I don't know how I can get around with.
Upvote 0

Alexander Stolte

Licensed User
java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.objects.collections.List.getSize()' on a null object reference
ASTabStrip1.AddTab("Current_Order", "Current Orders",Null,"")
look at the Example, youre using the class wrong.

  1. Initialize the TabMenu and ViewPager
    1. B4X:
  2. Add a tab
    1. B4X:
          Dim tmp_xpnl As B4XView = xui.CreatePanel("")
              ASTabStrip1.AddPage(xui.Color_ARGB(255,39, 174, 97),"Tab " & i,GetRandomIcon,"",tmp_xpnl,"")
Upvote 0