Button Images not displaying

Bryan

Member
Licensed User
Longtime User
I have a Samsung Note 8 tablet running android 4.1.2. I'm using B4A 2.52 currently. I have created a panel with 2 buttons in designer. For the buttons I have used .png images the same size as the buttons. They were created in photoshop. The panel with the two buttons are used for a widget. In the B4A designer app on the device the images display correctly. After compiling the code the buttons are just gray boxes but still function normally. I cannot figure out what to do to make the images display. Could this be related to the android 4.1.2 OS? Would updating to B4A 2.72 fix this problem? Should I just assign the images to the buttons in code instead? Help is always greatly appreciated.

Thanks,
Bryan
 

Bryan

Member
Licensed User
Longtime User
It is most probably not related to the OS version. Can you upload your layout file with the images?
I see now that I cannot use statelistdrawable for buttons in designer for widgets. Instead I used imageview for the buttons. This works out nicely to create buttons except I would like to be able to display a pressed state for these buttons. I decided to load new images that would display a pressed state for the buttons on imageview_click event. This works but is way to fast to even see the change of images. Is there a simple way to slow it down so the "pressed state" image is displayed a little longer before I change it back to the "un-pressed state" image.
Here is what I am doing. I can barely see the change of the images because they switch too fast. I would need a delay possibly for a few milliseconds.
Shoul

B4X:
Sub ImageView1_click
    rv.SetImage("Imageview1",LoadBitmap(File.DirAssets,"BlankB.png"))
    rv.UpdateWidget
    rv.SetImage("Imageview1",LoadBitmap(File.DirAssets,"IN1.png"))
    rv.UpdateWidget
 
Upvote 0

Bryan

Member
Licensed User
Longtime User
Thanks, much I will give that a try. I was playing around with using beeper from the audio lib. I was setting it to a time to about 500 ms and a very low frequency that couldn't be easily heard and that worked good as a timer. But I'll try the timer method so I don't need to have to load an additional lib (audio) just for a delay.
 
Upvote 0

chrjak

Active Member
Licensed User
Longtime User
hey guys,
I have the same problem but its harder than his...
I would do it with an Imageview but i can't export my Buttons as Images... Always there are some corners...
Is there a trick to export the Button Design as Image?
Erel should know...
Regards
 
Upvote 0

colin van Blommestein

Member
Licensed User
Longtime User
The corners are part of the button background image. You can use Canvas.DrawDrawable to draw a button an a bitmap.

Hi Erel
I'm trying to resolve a DBUtils NullPointerException error


SQL.ExecNonQuery2(sb.ToString, args)
The sb string and args are correctly formatted

The sequence of events is

Extract a record
Populate edit objects
Change contents of edit object
UPDATE the record

Am I missing something in the sequence of events?
 
Upvote 0

chrjak

Active Member
Licensed User
Longtime User
The corners are part of the button background image. You can use Canvas.DrawDrawable to draw a button an a bitmap.
How can i set the Button text?
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…