1

Maybe the name of the post isn't quite specific, but my english isn't so good, so sorry if you don't understand something. I'm relatively new on android. With that being said, I'm making a game on android which has differents levels. I have a levels menu, with buttons with the numbers of each level, so when you click one of them, the level is opened. It's quite simple and each level has a different image but the rest of the layout items are the same. Is there a way to make just a generic activity, so when it's called by a button it opens with the image to show or something like that, instead of making each level activity separetely? Thanks!

juanimoli
  • 61
  • 5
  • Call a single activity with different intent data and load the content in your activity based on the data received. – Malith Lakshan May 25 '16 at 01:18
  • You mean like call the activity with an specific parameter? And make the activity to respond to each specific parameter? – juanimoli May 25 '16 at 01:19
  • Yep. But as might know activities cannot be started by calling constructors with parameters. The most common way to achieve this is to pass the 'parameters' along with the intent. – Malith Lakshan May 25 '16 at 01:21
  • Sorry if I duplicated the post, I'm also new here, don't know how to search correctly. I will try that, thanks! – juanimoli May 25 '16 at 01:24
  • As what @MalithLakshan said, I also think the way to do this is to pass data to your Activity using Intents. Then have the activity behave according to the data passed. With regards to the possible duplicate, the idea is the same. – AL. May 25 '16 at 01:24
  • No worries. Good luck with your game. Cheers! :) – AL. May 25 '16 at 01:25

0 Answers0