Send.Bitmap=Bitmap1 not working. What am i doing wrong?

nad

Active Member
Licensed User
Longtime User
Hello,

I have a panel with some views. One of them is a imageview. When I click the imageview i want to change the star image (staron/staroff) but it is not working. What i am missing?

Any help appreciated.

Thanks a lot,


Sub imvStar_click
Dim send As ImageView
send=Sender


Dim Bitmap1 As Bitmap

Log("Fav("&send.Tag&")="&Favorito.Get(send.Tag))

If Favorito.Get(send.Tag)<>"1" Then
'ACTIVAMOS FAVORITO
'==================

Favorito.Set(send.Tag,"1")
Bitmap1.Initialize(File.DirAssets,"starOn.png")​

Else
'DESACTIVAMOS FAVORITO
'=====================

Favorito.Set(send.Tag,"0")
Bitmap1.Initialize(File.DirAssets,"starOff.png")​

End If
send.Bitmap=Bitmap1
SaveFavoritos​

End Sub​
 
Last edited:
You could just use a BOOLEAN variable to load the pic you want, for example:

Code:
If Variable = True Then

   Variable = False

   Load the On picture

Else

   Variable = True

   Load the Off picture

End If
 
Upvote 0
Thanks a lot for your reply!

I did not expain myself clearly. The problem is the following

Bitmap1.Initialize(File.DirAssets,"starOff.png")

send.Bitmap=Bitmap1

For some reason send.Bitmap=Bitmap1 is not working

Don't really care what is stored in the list, that part is working fine with 0 and 1 or boolean as you say

Cheers,
 
Upvote 0
Thanks!

I am not sure i understand you and where i am complicating it.

I am using a list (Favorito) because i have sliding panels you can move touching them. Everyone of them has a star. This star is disabled by default (staroff.png). When user clicks it, i want to enable it (loading the staron.png/staroff.png), store that in the list (don't really care if it is a list of boolean or a list of 1s and 0s) and saving the list to disk.

When user clicks the star, i try to get the sender and change the bitmap with staron/staroff but it is not working.

Really i don't see where would you include the boolean? I do not understand your idea.



Code:
Sub imvStar_click
   Dim send As ImageView
   send=Sender
   
   
   Dim Bitmap1 As Bitmap
   
   Log("F("&send.Tag&")="&Favorito.Get(send.Tag))
   
   If Favorito.Get(send.Tag)=False Then 
      'ACTIVAMOS FAVORITO
      '==================
      Favorito.Set(send.Tag,True)
      Bitmap1.Initialize(File.DirAssets,"star.png")
      
   Else
      'DESACTIVAMOS FAVORITO
      '=====================
      Favorito.Set(send.Tag,False)
      Bitmap1.Initialize(File.DirAssets,"star2.png")      
      
   End If

   send.Bitmap=Bitmap1
   SaveFavoritos

End Sub

I changed it as you say but it is also failing, the problem is not what i use to decide if activate or not, but the send.Bitmap=Bitmap1 that is not working

oh well i think it might be that the send.tag is not sending the correct number on the list


Cheers,
 
Last edited:
Upvote 0
This makes more sense, but still is not working. But now at least the Favorite is the same index number as the panel (changed send.tag by sd.currentpanel)

Code:
Sub imvStar_click
   Dim send As ImageView
   send=Sender
   
   
   Dim Bitmap1 As Bitmap
   
   Log("F("&sd.currentPanel&")="&Favorito.Get(sd.currentPanel))
   
   If Favorito.Get(sd.currentPanel)=False Then 
      'ACTIVAMOS FAVORITO
      '==================
      Favorito.Set(sd.currentPanel,True)
      Bitmap1.Initialize(File.DirAssets,"star.png")
      
   Else
      'DESACTIVAMOS FAVORITO
      '=====================
      Favorito.Set(sd.currentPanel,False)
      Bitmap1.Initialize(File.DirAssets,"star2.png")      
      
   End If

   send.Bitmap=Bitmap1
   SaveFavoritos

End Sub
 
Upvote 0
One thousand thanks for your help!!

You code works wonderfully but when i translate it to my code it is not working. I am using the Animation library. I am wondering if that is the reason it is not working.

(Dim sd As SlidingData 'The object that holds the data for SlidingPanels)




Code:
Sub imvStar_click
   
   
   Dim bmap As Bitmap
   Dim pic As ImageView
   
   pic=Sender
   
   Log("F("&sd.currentPanel&")="&Favorito.Get(sd.currentPanel))
   
   If Favorito.Get(sd.currentPanel)=False Then 
      'ACTIVAMOS FAVORITO
      '==================
      Favorito.Set(sd.currentPanel,True)
      bmap.Initialize(File.DirAssets,"star.png")
      
   Else
      'DESACTIVAMOS FAVORITO
      '=====================
      Favorito.Set(sd.currentPanel,False)
      bmap.Initialize(File.DirAssets,"star2.png")      
      
   End If


   
   pic.Bitmap=bmap
   
   
   SaveFavoritos

End Sub


This is what i get in the log, so it is working fine, changing status every time i click the star for panels 0 and 1 but the image is not being updated

F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(0)=true
Saved favorites
F(0)=false
Saved favorites
F(1)=true
Saved favorites
F(1)=false
Saved favorites
F(1)=true
Saved favorites
F(1)=false
Saved favorites
 
Upvote 0
Thanks to your hint i've found it and now it works :sign0060:

When initializing all the panels I was using only one imvStar.initialize("imvStar") and imvStar.tag inside a For so it was always passing as tag the last value of the for.

:BangHead:

Thanks a lot for your awesome help and the other animation library looks great, i have to change to that one in the future. I will try to post the app tomorrow in the shared apps thread

Cheers ;-) and thanks again !!
 
Upvote 0
Back
Top