猴子达人吧 关注:0贴子:237
  • 3回复贴,共1

App Components-->Activities

只看楼主收藏回复

An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and takes user focus. The back stack abides to the basic "last in, first out" stack mechanism, so, when the user is done with the current activity and presses the Back button, it is popped from the stack (and destroyed) and the previous activity resumes.


IP属地:广东1楼2015-02-04 10:13回复
    You can set the layout as the UI for your activity with setContentView(), passing the resource ID for the layout. However, you can also create new Views in your activity code and build a view hierarchy by inserting new Views into a ViewGroup, then use that layout by passing the root ViewGroup tosetContentView().


    IP属地:广东2楼2015-02-04 10:16
    回复
      Starting an activity for a result--->>
      Sometimes, you might want to receive a result from the activity that you start. In that case, start the activity by calling startActivityForResult() (instead of startActivity()). To then receive the result from the subsequent activity, implement the onActivityResult() callback method. When the subsequent activity is done, it returns a result in an Intent to your onActivityResult() method.


      IP属地:广东3楼2015-02-04 10:18
      回复
        生命周期方法:onSaveInstanceStace() and on RestoreInstanceState()用来状态保存,onSaveInstanceStace会在onstop之前调用或者onPause之前调用。


        IP属地:广东5楼2015-02-04 10:59
        回复