Android Question creating UI not based on the designer objects

zohar

Member
Licensed User
Longtime User
Hi

what are the preferred ways to create customized UI ?
for example , ive attached a picture of snakes and ladders .
suppose i want to create my menus with the same layout , so each cell represent a button and will be clickable .
for example pressing on 25 will do x and pressing on 40 will do y .

thanks in advance .
 

Attachments

  • snakes.jpeg
    snakes.jpeg
    48.2 KB · Views: 724
Hi .

Thanks for the tip it works .
ive created image object and add few labels .
the code below show 2 clicks's subs which call show_count .


how to change the code below to work with array (lblapple = Array As Label(apple1, apple2, apple3, apple4, apple5))
so each time i click the button, show_count will change the label to disable and i will be able to check the order of the clicks (apple1 first , apple2 second etc ..)



Sub show_count
countlabels=countlabels+1
If countlabels=4 Then
Msgbox("Finished","Great")
MediaPlayer1.Initialize( )
MediaPlayer1.Load(File.DirAssets, "einav.mp3")
MediaPlayer1.Play
End If
End Sub


Sub apple1_Click
show_count
apple1.Enabled=False
End Sub


Sub apple2_Click
show_count
apple2.Enabled=False
End Sub


Sub apple3_click
..
..
..

Thanks ,
Zohar
 
Upvote 0
Please use code tags

I am not sure I understood what you want but you might want to use sender keyword
All lables should have the same event name and you add only one sub like
Code: Copy
Sub apple_Click
    dim s as label = Sender
    s.Enabled=False
   ....

End sub
 
Upvote 0
Please use code tags

I am not sure I understood what you want but you might want to use sender keyword
All lables should have the same event name and you add only one sub like
Code: Copy
Sub apple_Click
    dim s as label = Sender
    s.Enabled=False
   ....

End sub
thanks for the quick reply
but what i actually want is to be able to manipulate the label attribute from different SUB.
this way all the logic will be outside the apple_Click .
in pseudo code :
click on label -> call other sub which will verify if the label can be clicked now --> do something --> disable the label so it cannot be clicked.

this routine should be run for multiple labels , and i want to centralized my code as much as possible .
 
Upvote 0
Are your labels global ?
You should be able to manipulate views from any sub if you declare them inside Sub Globals
 
Upvote 0
Are your labels global ?
You should be able to manipulate views from any sub if you declare them inside Sub Globals
Hi

I have global varaible still i can't understand how to pass the information the other sub .

here is a code example :
and i still can't understand , when i click on apple1_click how to pass to show_count that i press on label apple1 .
i want that show_count will be aware to which label clicked , so if i press apple1/apple2/apple3 show_count will be able to manipulate the label .

Code: Copy
Sub Globals
            Private apple1 As Label
        Private apple2 As Label
        Private apple3 As Label
        Private apple4 As Label
        Private apple5 As Label
        Dim countlabels As Int   
        countlabels=0  
End Sub



Sub apple1_Click
         show_count
        apple1.Enabled=False
End Sub


Sub show_count
    countlabels=countlabels+1
    If countlabels=4 Then
        Msgbox("Finished","Great")
        MediaPlayer1.Initialize( )
   MediaPlayer1.Load(File.DirAssets, "einav.mp3")
    MediaPlayer1.Play
    End If   
    End Sub
 
Upvote 0
Maybe
Code: Copy
Sub apple1_Click
        dim l as label=sender
         show_count(l)
        apple1.Enabled=False
End Sub
Code: Copy
sub show_count (sendr as label)
    'sendr is the clicked label
    
end sub
 
Upvote 0
Maybe
Code: Copy
Sub apple1_Click
        dim l as label=sender
         show_count(l)
        apple1.Enabled=False
End Sub
Code: Copy
sub show_count (sendr as label)
    'sendr is the clicked label
 
end sub

Great , this example work .
i was able to run :
Code: Copy
sub show_count (sendr as label)
    sendr.enabled=false
 
end sub

however , i still need to configure click function for each label ?
this function only send label apple1 and it is not respond to other labels .
is there a way that whatever label i choose will run with one click function and send the relevant label which was clicked ?
so for example , the following code will be able to react and send each label that i press :

Code: Copy
Sub general_Click
        dim l as label=sender
         show_count(l)
End Sub

Thanks ,
Zohar
 
Upvote 0
Back
Top