简体   繁体   中英

Android application structure issue

I'm working on application and I need some suggestions which is the best way to code it for Android. Basically it's something like event guide for a few cities. Imagine this :

I have an activity with 7 different buttons (7 different cities) and clicking on one of these buttons I'm opening a new activity where I have all months (January-December) as buttons again. If there is some event in February for example in the chosen city the button will be active and I will go to another activity where I have a list with the events. So my idea is to do it in this way :

  1. Create one Activity with all Cities
  2. Create one Calendar activity with all months.
  3. When user select for example Paris, I'll send an extra via intent with an ID of the chosen city :

    intent.putExtra("chosenCity", 2); //something like this

  4. In the Calendar activity I will make active/inactive months buttons depending on that extra sent from Cities activity.

  5. And when user chose a month I will send that chosenCity extra again to the ListViewEvents activity and populate the list view from Database (for example) depending on that extra .

So my question is : is it a good way to build an application like that? Or if it's not, which is the best way to achieve this?

Thanks in advance!

Sounds like you already know pretty much what you need to do. The only thing left is to implement it. The only thing I'll add is that your should probably store all your database and use a CursorAdapter to display them in the ListView. You can store all the events in the database and just create your select statement in such a way that it only selects the events you want to display at any given time. When using this CursorAdapter, I highly recommend you use the CursorLoader .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM