views:

58

answers:

2

Does Android have an equivalent to Cocoa's viewDidLoad and viewDidAppear functions?

If not, then how would I go about performing an action when a View appears? My app is a tabbed application, in which one of the tabs is a list of forum topics. I would like the topic list to be refreshed every time the view appears. Is such a thing possible in Android?

+1  A: 

The Activity class has onCreate and onResume methods that are pretty analagous to viewDidLoad and viewDidAppear.

Activity.onResume

Rich
+1  A: 

From my limited, nascent understanding of Android, you implement viewDidLoad type functionality in the onCreate method of your Activity:

onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically.

The equivalent for viewDidAppear is closer to the onResume method:

Called after onRestoreInstanceState(Bundle), onRestart(), or onPause(), for your activity to start interacting with the user. This is a good place to begin animations, open exclusive-access devices (such as the camera), etc.

Cannonade