Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android: Randomly swap buttons positions to predefined positions

 
Philip Bayston
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having trouble working out how to implement an idea I have had. I have 9 buttons number 1,2,3... and so on. The 9 buttons are layed out as if it is a three by three grid. I need to keep this layout but I want to swap the images around the predefined locations for example the layout of the buttons might be like so:

1 2 3
4 5 6
7 8 9

but upon button press the layout would randomly swap keeping the square shape and may look like this:
9 1 5
7 8 3
2 6 4

each button press would randomly swap the buttons around keeping the above structure.

I understand how to set button position programmatically but yet to figure out away to achieve what I want or at least efficiently. This is my class so far for setting the button location which all it does is set images in totally random places:


A different idea i have sets the images location corretly but keeps it static as I haven't figured out how to combine the random without breaking my design plan.:


Guidance on this would be great, hopefully I have explained my goal clear enough. I can find loads on randomly moving images and button but not cycling them through predefined coords
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic