Android Question CustomView Background

Guenter Becker

Active Member
Licensed User
Longtime User
Hello I like to set the Background of the Custom View to a GradiendDrawable by code like it is done by the Designer Properties.
[CODE lang="b4x" title="I tried this:" highlight="9"] Dim ColorArray(2) As Int
ColorArray(0) = DisabledColor
ColorArray(1) = xui.Color_White
Dim dr As GradientDrawable
Dim Ori As String = mprops.Get("orientation")
dr.Initialize(Ori,ColorArray)
dr.CornerRadius = mprops.Get("gradradius")
Dim PNL As Panel = mBase
PNL.Background = dr
mBase=PNL[/CODE]
[CODE lang="b4x" title="get this error on line PNL.Background = dr"]Error occurred on line: 249 (TDextPanel)
java.lang.ClassCastException: android.graphics.drawable.GradientDrawable cannot be cast to android.view.View
at anywheresoftware.b4a.objects.ViewWrapper.setBackground(ViewWrapper.java:105)
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:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[/CODE]

What I'm doing wrong?
 
Good Morning Erel,
it is the code I tried. Anyway I hope I make myself clear In some situation the Developermust or will be able to change the Text and Background (Drawable) Properties by code. To realize it some set/get Subs may be coded to set/change the the Designer (Basae) Properties values. At present I understood that the Designer Text Properties are reflected by the LBL View in the DesignerCreate Sub. But I do not know how to get access to the Drawable Properties. The only one is Background but that is also no way to adress the Properties. The easiest way will be to have all the Properties of the Base acessible via the Base Object but this is not possible at present because Base is an Object and does not have the requested Properties.

Therefore my question is still unanswered: How to get access to all of the Properties of the Base especially to the Drawable/Background ones?
 
Upvote 0
Back
Top