I’m a newbie on android development. I’ve been working on this app for my school project. The app is basically a calculator which calculates the cost of the energy consumption of the home appliances. In my screen, I have a bunch of imageViews of the home appliances in my viewFlipper so the user can navigate through the images in order to select an appliance that he wants it be calculated. My question is, how to assign integer values (Such as the watt of the appliance or its specs) in an efficient way to these imageViews so the app can calculate the energy consumption based on the selected image? Im using conditional statements but it seems to be too much coding and it wastes memory because I have over 40 Image views. Should I use an Sql database and put all the specs and the pictures of the appliances in a table and call it from there as the user selects it or is there a way to make something in the xml such as arrays or lists?
Share
Consider creating a class which extends ImageView. You can then pass objects to your custom class, e.g., passing an object (which stores all your energy related data) to the constructor of your custom ImageView class. e.g.,
Or you could setTag on an ImageView.
Working with 40 ImageViews? I forsee OutOfMemoryError problems if memory mgmt is not handled properly. Be careful!