Android Question Show Panel Class when Click

Gardea

Member
Licensed User
Longtime User
Hi,
I created a class with a custom panel and I want to showing the panel when i click the table cell

This is a sample of my code :
In MAIN

B4X:
Sub Globals
                  
         Private dbtable As Table
        Private dipilih As PilihRT
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    dbtable.Initialize(Me,"dbtable",5)
    dbtable.AddToActivity(Activity,0,0dip,100%x,80%y)
    dbtable.HeaderColor=Colors.Blue
    dbtable.HeaderFontColor=Colors.White
    dbtable.SetHeader(Array As String("Loker","Customer","Room","Terapis","Waktu"))
   
    dipilih.Initialize
   
End Sub

Sub dbtable_CellClick(Col As Int, Row As Int)
    dipilih.Show
End Sub

in CLASS PilihRT

B4X:
Sub Class_Globals
    Private Room As Spinner
    Private Terapis As Spinner
    Private BtnWaktu As Button
    Private BtnCancel As Button
    Private BtnOK As Button
    Private Panel1 As Panel
End Sub

Public Sub Initialize
   
End Sub

Public Sub Show
    Panel1.LoadLayout("PilihTerapis")
    Panel1.SetVisibleAnimated(500,True)
End Sub

But it always stop at Panel1.LoadLayout("PilihTerapis")

Sorry for very newbie question....
Please help....
Thank You...
 

sorex

Expert
Licensed User
Longtime User
panel1 is not initialized.

I don't see it initialized and added to something by code or loaded via a loadlayout.
 
Upvote 0

Gardea

Member
Licensed User
Longtime User
Did you get any ERROR? Which error?
Post as much Information as possible.
Sorry, This is the error :

B4X:
Error occurred on line: 23 (PilihRT)
java.lang.RuntimeException: Object should first be initialized (Panel).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:116)
    at b4a.example.pilihrt._show(pilihrt.java:77)
    at b4a.example.main._dbtable_cellclick(main.java:454)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:847)
    at b4a.example.table._cell_click(table.java:443)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:5685)
    at android.view.View$PerformClick.run(View.java:22481)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:241)
    at android.app.ActivityThread.main(ActivityThread.java:6274)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 
Upvote 0

Gardea

Member
Licensed User
Longtime User
panel1 is not initialized.

I don't see it initialized and added to something by code or loaded via a loadlayout.

I add this :

B4X:
Public Sub Show
    Log("load PilihTerapis Layout")
    Panel1.Initialize("Panel1")
    Panel1.LoadLayout("PilihTerapis")
    Panel1.SetVisibleAnimated(500,True)
End Sub

But it not show
and in Logs is

B4X:
Panel size is unknown. Layout may not be loaded correctly.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I think that you need to explain more in detail what exactly you want to do.
Do you really need a Class?
If yes, do you want a Standard Class or a CustomView?
For CustomViews you may read the B4x CustomViews booklet which includes examples, link in my signature.
You could use a Panel and show or hide it without a Class.
But without knowing the details it's difficult to give you a concrete advice.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…