Set background picture error

Hey, anyone having troubles setting background picture for buttons? Without any specific pattern or cause, the picture I set gets removed from the block.
I have already recreated multiple times the same blocks, uploaded new images with other names and even deleted and recreate again the buttons. Nothing appears to work

Hi @rojored12,

I would advise using a variable to store the name/path of your image and then using the value of that variable to set your background image.

This will make your blocks more resilient to future changes.

Thanks! For now it´s working smoothly. Any changes I´ll let you know.

1 Like

Hey there again, I’ve just made my first test with the .APK file on Android and it seems that none of the pictures I have as variables, don’t show up; whereas the rest of the pictures set directly as pictures do. Any problems like this before?

Are they properly set to the local path?

Can you paste a few block examples of how you set your image variables please.

Actually I just set the variable as e.g. “image.png”, which works fine with the thunkable live app. I don’t think I know how to set the local path correctly.

I had no issues. I uploaded two pngs, and then created these blocks. I downloaded and tried the APK and it works fine. I need more info on the blocks causing an issue.

I´m sorry, I didn´t have my computer earlier that´s why I couldn´t show you my blocks.

At the left is the function in which all the images are set into variables; at right, 2 situations in which those variables are used.

As I mentioned before, all the images that are directly set to buttons backgrounds, same as you did in your previous example, work fine.

Add a label, and set the text of the label to the variables, as a test. I am confused why you are using join commands for your variable names. I have not seen that before, and do not think it is a good idea. I dont know if that is the cause or not.

For now set up a label to pass the variables you expect to. Then go from there.

The label testing did show the “text.png”, though it flickered in both the thunkable live and apk; and also both either with variables joining text and variables that don´t. However, the variable I tested with the label, did show successfully its respective image. The latter didn´t happen with the untested variables-label. Nevertheless, in the thunkable live, I´m still don´t having any issue showing the images of all variables properly.

Regarding why I use variables with joining text is because I have to store many lists when the user opens the list for the first time, and so on, without replacing the previously opened lists; and then retrieve the same local file when the user opens that list again; so I figured out that with that technique I could store under the same general stored variable e.g. “local_list” and then just add (join), an identifier for that specific list e.g. “_red” which is also a variable e.g. “selectedcolor”. All of these instead of initializing one variable for every single list thta I could possibly generate with my data (more than 35 lists) everytime the screen opens. I hope that I explained myself correctly and also that I didn´t screwed it hahaha. Btw If you happen to know a better way to do what I want to, I´m open to better ideas :wink:

PS: before using variables for my images, I was using list items, however they were really unstable when I used “If blocks” to set the image for a specific component as you can see in the first post of this thread