views:

71

answers:

3

I created an Activity which allows navigating between pages with a couple of Buttons (Previous and Next). When the user clicks one of the buttons, the Activity (same) needs to be "refreshed". In order to do this, I set up the buttons to make a call to

onCreate(this);

after they set up the other stuff that the activity uses for the paging to work.

And it is working so far, but I'm wondering if there is a better way. Is there?

A: 

You should rethink your approach. Having Previous and Next buttons looks like an iphone's NavigationBar View. Remember that in android you have the back button, so a previous button shouldn't be necessary.

If you wish to do it, check Android's Activity Lifecycle. You should update your Activity on the onStart() method and avoid the call to onCreate(this) which doesn't sound good.

Macarse
Doesn't it seam a little strange to only have a "Next" (and rely on the physical "Back" button) ? Thanks.
MyNameIsZero
A: 

The activity displays data related to a certain day. The navigation allows choosing the day which is being displayed. As such, clicking one of the buttons changes the information which is displayed.

Example:

When the Activity first loads, it shows a given day - let's say August 23rd. Then when the user clicks the activity's "Previous" Button, the Activity shows August 22nd.

Then the user clicks the "Next" button and the Activity shows August 23rd again. If the user clicks the "Next" button again, the Activity will show August 24th.


Doesn't it seam a little strange to only have a "Next" (and rely on the physical "Back" button) ?

Thanks.

MyNameIsZero