Android Question Rotate Button1.SetBackgroundImage???

ComposerB4A

Member
Licensed User
Longtime User
Hello to all,
One Question, How rotate one Button1.SetBackgroundImage??
i have two buttons, the first with image and other not, and the seconds button in future set image rotated

Dim BM1 As Bitmap, BM2 As Bitmap, RSI1 As RSImageProcessing
BM1.Initialize3(Button1.Background.Bitmap)
BM2 = RSI1.rotateBitmap(BM1,90)
Button2.SetBackgroundImage(BM2)
 

ComposerB4A

Member
Licensed User
Longtime User
B4A say:
Error compiling program.
Error description: Unknown type: android.graphics.drawable.Drawable
Are you missing a library reference?
Occurred on line: 63
BM1.Initialize3(Button1.Background.Bitmap)
Word: bitmap
 
Upvote 0

ComposerB4A

Member
Licensed User
Longtime User
Hi, B4A say:

LogCat connected to: emulator-5554
** Activity (main) Create, isFirst = true **

main_activity_create (B4A line: 31)

Dim BMD1 As BitmapDrawable = Button1.Background
java.lang.RuntimeException: Object should first be initialized (Button).

Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
at anywheresoftware.b4a.objects.ViewWrapper.getBackground(ViewWrapper.java:85)
at anywheresoftware.b4a.samples.animation.main._activity_create(main.java:281)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.samples.animation.main.afterFirstLayout(main.java:89)
at anywheresoftware.b4a.samples.animation.main.access$100(main.java:16)
at anywheresoftware.b4a.samples.animation.main$WaitForLayout.run(main.java:74)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)

at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (Button).

Did you forget to call Activity.LoadLayout?
** Activity (main) Create, isFirst = true **

** Activity (main) Resume **

main_activity_longclick (B4A line: 94)

Dim BMD1 As BitmapDrawable = Button1.Background
java.lang.ClassCastException: android.graphics.drawable.StateListDrawable

at anywheresoftware.b4a.samples.animation.main._activity_longclick(main.java:403)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$2.onLongClick(ViewWrapper.java:73)
at android.view.View.performLongClick(View.java:2503)
at android.view.View$CheckForLongPress.run(View.java:9056)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

ComposerB4A

Member
Licensed User
Longtime User
Thanks,
¿how load one image in (visual) designer in one button (set BitmapDrawable)?

for work in this moment, i use this code, because the image files exist in folder "files" (saved) is same that (visual) designer, is same that function "File.DirAssets"
Dim BM1 As Bitmap, BM2 As Bitmap,C1 As Canvas, RSI1 As RSImageProcessing
BM1.Initialize(File.DirAssets,"compass2.png")
BM2 = RSI1.rotateBitmap(BM1,90)
Button2.SetBackgroundImage(BM2)
 
Upvote 0
Top