Class compile problem

Ricky D

Well-Known Member
Licensed User
Longtime User
B4X:
'Class module myInput
Sub Class_Globals
   Private pnl As Panel
   Private lTitle As Label
   Private aceInput As AutoCompleteEditText 
   Private bOk As Button 
   Private bCancel As Button 
   Private meobj As Object 
   Private act1 As Activity 
   Public Input As Object
End Sub

'Initializes the object. You can add parameters to this method if needed.
Sub Initialize(meObjIn As Object, act As activity, Title As String)
   meobj = meObjIn
   act1 = act
   pnl.Initialize("pnl")
   lTitle.Initialize("lTitle")
   aceInput.Initialize("aceInput")
   bOk.Initialize("bOk")
   bCancel.Initialize("bCancel")
   
   pnl.Tag = "CUSTOMINPUT"
   pnl.Visible = False
   lTitle.Text = Title
   lTitle.Gravity = Gravity.CENTER_HORIZONTAL
   lTitle.Typeface = Typeface.DEFAULT_BOLD
   pnl.AddView(lTitle, 0, 0, 100%y, 100%x)
   act.AddView(pnl, 0, 0, 100%y, 100%x)
End Sub

Public Sub Show(Title As String)
   lTitle.Text = Title
   pnl.Visible = True
End Sub

Public Sub Hide
   'remove the panel from the activity
   For i=0 To act1.NumberOfViews-1
      Dim o As View 
      
      o = act1.GetView(i)
      
      If o Is Panel Then
         pnl = o
         
         If pnl.Tag="CUSTOMINPUT" Then
            act1.RemoveView(pnl)
         End If
      End If
   Next
End Sub

that's my entire class so far but have hit a snag

this is what the compiler says

Compiling code. Error
Error compiling program.
Error description: Object reference not set to an instance of an object.
Occurred on line: 48
act1.RemoveView(pnl)
Word: (

Line 48 is act1.RemoveView(pnl)

I can't figure this out.
:BangHead:

regards, Ricky
 

Ricky D

Well-Known Member
Licensed User
Longtime User
found the problem.

I was using RemoveView incorrectly

regards, Ricky
 
Upvote 0
Top