0

I developed an app for the iPhone that I would like to make for Android. However, because I was self taught with Xcode, I approached the project incorrectly. My app in it's basics loads a certain picture from a List View when the user selects the certain button associated with the picture they want. I had no programming experience when I started, so I just linked by drag and dropping roughly 300 buttons to 300 different scenes which displayed 300 different pictures in Xcode. Yes, it was very time consuming... My question is how should I approach my project to do the same function in Android Studio, but minimizing the amount of activities. I have the idea that it would be more beneficial to use code to have one List View activity that incorporates many buttons, that when pressed, will display the particular picture. Any recommendations for tutorials or videos as a place to start as I learn my way around Android Studio? Or am is it hopeless and I will have to have another roughly 300 Activities in Android Studio.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
beans217
  • 139
  • 2
  • 11
  • You can have 300 buttons on one Activity. All launch one Activity that displays one out of 300 images. – OneCricketeer Oct 11 '16 at 15:57
  • That's exactly the code I am trying to figure out how to do. Any suggestions? – beans217 May 26 '17 at 18:12
  • You've not accomplished this in half a year, still? `ListView` and `ArrayAdapter` would be a great start for you to look at. You just store a list of 300 elements, and create buttons from them. – OneCricketeer May 26 '17 at 19:13

1 Answers1

0

You can use fragment for acheving your purpose.

A Fragment is a piece of an activity which enable more modular activity design. It will not be wrong if we say, a fragment is a kind of sub-activity

Fragment you can think of it like a sub activity, which sits with in an activity and which contributes its own UI to the activity screen. Fragments are always part of an activity. With out an activity, a fragment will not exist. So your fragment life cycle will always be affected by activity life cycle. An activity can contain more than one fragment. Similarly a fragment can be re used in multiple activities

Below links will help you to know more about fragment and how it's implemented in an android application

Ryan R. Rosario
  • 5,114
  • 9
  • 41
  • 56
Rissmon Suresh
  • 13,173
  • 5
  • 29
  • 38