Well I am new to android and it is my first app so thought I should take a simple project. The app is a book. You see a list of titles and you select one then the text for that title appears. I wanted the design to be in a way that when I add a new title I add its name at most at one place in the code. My first idea was to have two activities. The "rootAct" shows the list and "title_viewAct" displays the article body. It could be done by "rootAct" telling which title was chosen to title_viewAct then title_viewAct could call setContentView() on the appropriate layout file. The problem is this design is that rootAct cannot populate the list based on the layout XMLs alone. I couldn't find a way to populate the list in a correct manner by reading data from resources. Should I create an activity for each title instead of using one activity? Or I can create a global list of pairs of {entry_name,entry_resource_name} and populate the list with entry_names then title_viewAct can set the right layout to display.
Beside all these is there a place to use fragments here?
The question is what is the best design pattern for this app?
Aucun commentaire:
Enregistrer un commentaire