Android Question CustomView Background

Guenter Becker

Active Member
Licensed 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.
I tried this::
                    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.CornerRadius = mprops.Get("gradradius")
                    Dim PNL As Panel = mBase
                    PNL.Background = dr
get this error on line PNL.Background = dr:
Error occurred on line: 249 (TDextPanel)
java.lang.ClassCastException: cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.ViewWrapper.setBackground(
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent(
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(
    at android.view.View.performClick(
    at android.view.View.performClickInternal(
    at android.view.View.access$3100(
    at android.view.View$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)

What I'm doing wrong?

Guenter Becker

Active Member
Licensed User
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