• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Am I developing this application correctly?

Deemar

Newbie
Feb 7, 2012
38
2
I couldn't find a specific support forum here, I'm hoping I posted this in the right place and someone can help me.

Right now I have an Android application I made and it has a list of items I can select. The list of items is displayed from an array of Strings and I use a case switch to check which one was clicked. This is very bad because it's a case switch which checks the ID of the clicked item and there are 180 items. So if you add another item somewhere in the middle, you have to manually change the subsequent case switch ID to be increased by one. Know what I mean? Is there a better way to find out which one has been pressed so an action can be associated to it?

Also on the same application, clicking a menu item displays information about that item including a photo and some text details. Every detail page is the same except for the content but right now I have a separate .java file for each page and also a separate .xml file for the layout of each page. Each .java file calls its own .xml file and each .xml file calls its own photo image and String for the details. So this means I have 180 .java files, 180 .xml files and 180 .png images.

Is there a better way to dynamically create these so I don't have so many files? Thanks everyone.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones