Android Question B4A - How to connect from Designer objects to manage with code - SENDER

AlexOfOz

Active Member
Licensed User
Hello. I've been battling with this for weeks and weeks, so I really have tried to figure it out.

But I have failed. :-(

Firstly, in the past couple of months I have had pleasing success and even have 2 projects published on the Google App Store.

But there is one thing (so far) that I simply can't wrap my head around, no matter how hard I try. And that is, how do I make the connection from objects built with the DESIGNER to be able to manage them within the code? Yes, I have managed to do it .... both published programs make the connection .... but the honest truth is I still don't truly understand how the connection works.

Can somebody please help me understand the connection. If I create 36 ImageViews in the Designer, how do I transfer that over to be able to manage them in the code using a 1 dimensional array?

I know that sounds like a dumb question, but I'm confused. There are a number of requirements and I just can't get my head around it, even though I have accidentally achieved it with the 2 published programs.

Dim img as ImageView
tile as Array(img1, img2, img3, ..........
For a = 0 to 35
tile(a).Tag = a
Next

What am I not understanding? The above is just a simple example of where I'm getting lost. Any help will be appreciated.

play.google.com/store/apps/details?id=chasethe.square
play.google.com/store/apps/details?id=thememory.game

Alex
 

AlexOfOz

Active Member
Licensed User
Sorry Erel. That was just an example of the simplicity of what I'm trying to do but am failing.

I'm not asking for help with actual code, just the method for making the connection from the object in the designer across to the code.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
Yes Erel, thank-you very, very much. The video is almost exactly the sort of thing that I'm trying to do. I really appreciate your help.

Just as a note - one of the projects I have loaded to Google was originally long coded as over 2000 lines of code. Using help from forum members with SENDER I was able to bring that down to approximately 40 lines.

I appreciate your help and will only ask when I've run out of hope.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Hi AlexOfOz:

Before fall into despair, try the forum search, try several key words.
I mean try: "array of view", or "sender" or... you know. Every search may guide you to another finest search, until reach the right one.
 
Upvote 0

AlexOfOz

Active Member
Licensed User
Thanks Jose. I appreciate your help.
And yes Erel, the video has given me what I need to progress. I was just missing a true understanding of the connection from the objects in the designer and the code. Your video has shown me what I needed to know. I now have a good understanding of SENDER and a reasonable understanding of single dimensional arrays. Multiple dimensional arrays will need to wait. ;-)
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Thanks Jose. I appreciate your help.
And yes Erel, the video has given me what I need to progress.

You should in fact watch all the videos, you would have learnt about the SENDER sooner rather than later, thus it would have saved you a lot of wasted development time...
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Change your code to this:
B4X:
Dim img1, img2, img3, ....., img35, img36 As ImageView
Dim tile() as ImageView
tile =  Array As  ImageView (img1, img2, img3, ..... , img35, img36)
For a = 0 to 35
tile(a).Tag = a
Next
Then tile(0) is the same view as img1, tile(1) is the same view as img2 etc.
tile(0).Left is the same as img1.Left
 
Upvote 0

AlexOfOz

Active Member
Licensed User
klaus, everybody, I can't thank you all enough. I'm going to be working through the video and all of the other information tonight. I'm certain that it all answers those missing pieces I had in my understanding.

This group is marvellous. Thank-you. If you get a chance, I encourage you to have a look at the memory game link above. That program works, but is the one that I'll be applying my new learning to.
 
Upvote 0
Top