Hi guys,
I have CustomView compiled with B4A 11.8, that raised error :
java.lang.RuntimeException:
Object should first be initialized
(Java Object)
But, error only raised in specific phone with Android 11. Other phones, included others OS, not error raised.
Customview is added via Layout.
Here are the codes for Custom View
On those codes above, LogColor("3",Colors.Cyan) never reached.
I am confused, because on others phones with same/different OS, no error raised.
Can not get a hand of a phone because it is belong to a user.
So, what's wrong with my codes.
I have CustomView compiled with B4A 11.8, that raised error :
java.lang.RuntimeException:
Object should first be initialized
(Java Object)
But, error only raised in specific phone with Android 11. Other phones, included others OS, not error raised.
Customview is added via Layout.
Here are the codes for Custom View
B4X:
Sub Class_Globals
Private EventName As String 'ignore
Private CallBack As Object 'ignore
Private mBase As Panel
Private pnlDummy As Panel
Private left,top,width,height As Int
Private pnlLv As Panel
Private lbDB As Label
Private imgArrow As ImageView
Private ActiveTxtBoxBorderColor = Colors.RGB(128,0,0) As Int
Private TxtBoxColor = Colors.ARGB(150,32,32,32) As Int'Colors.ARGB(255,224,224,224) As Int
Private InActiveTxtBoxBorderColor = Colors.ARGB(200,32,32,32) As Int'Colors.Black' Colors.RGB(192,192,192) As Int
Private BorderWidth = 4 As Int
Private KYB As IME
Private lv As ListView
End Sub
Public Sub Initialize (Target As Object, Event As String)
LogColor("ini",Colors.Cyan)
EventName = Event
CallBack = Target
KYB.Initialize("")
lbDB.Initialize("lbDb")
lbDB.TextColor = Colors.White
lbDB.TextSize = 16
lbDB.Gravity = Gravity.LEFT + Gravity.CENTER_VERTICAL
imgArrow.Initialize("")
lv.Initialize("lv")
lv.SingleLineLayout.Label.TextSize = lbDB.TextSize
Private bd As GradientDrawable
Private col(2) As Int
col(0) = Colors.RGB(105,105,105)
col(1) = Colors.Black
bd.Initialize("TOP_BOTTOM",col)
lv.Color = TxtBoxColor' Colors.RGB(48,48,48)
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
LogColor("create",Colors.Cyan)
Private CD As ColorDrawable
CD.Initialize2(TxtBoxColor,7,BorderWidth, InActiveTxtBoxBorderColor)
mBase = Base
imgArrow.Bitmap = LoadBitmap(File.DirAssets,"arrow-white.png")
lbDB.Text = Lbl.Text
Base.Background = CD
Base.AddView(imgArrow,Base.Width-40dip,0,25dip, Base.Height)
Base.AddView(lbDB,10dip,0,Base.Width,Base.Height)
pnlDummy.Initialize("pnlDummy")
pnlDummy.Color = Colors.Transparent
pnlDummy.Visible = False
pnlLv.Initialize("pnlLv")
pnlLv.Color = Colors.Transparent
LogColor("1",Colors.Cyan)
Private Act As Activity
Act = Props.Get("activity")
Private CD As ColorDrawable
CD.Initialize2(TxtBoxColor,7,BorderWidth, ActiveTxtBoxBorderColor)
Act.AddView(pnlDummy,0,0,100%x,100%y)
LogColor("2",Colors.Cyan)
left = Utility.GetRelativeLeft(mBase)
top = Utility.GetRelativeTop(mBase)+mBase.Height
width = mBase.Width
height = lv.SingleLineLayout.ItemHeight
pnlDummy.AddView(pnlLv,0,0,0,mBase.Height)
pnlLv.Background = CD
pnlLv.AddView(lv,0,0,0,pnlLv.Height-2dip)
LogColor("3",Colors.Cyan)
End Sub
I am confused, because on others phones with same/different OS, no error raised.
Can not get a hand of a phone because it is belong to a user.
So, what's wrong with my codes.
Last edited: