Is there any way to pass custom parameters from a activity to a sub-activity?
I tried to do it via a constructor by creating a object of the sub-activity in the main-activity and passing the desired parameters. But when i start the sub-activity via a Intent the program fails.
The parameter I'm trying to pass is the main-activity.
Thanks for all 开发者_运维百科response!
Put extras on the Intent
you pass to startActivity()
. You will find a series of putExtra()
methods, and corresponding getters, on the Intent
class. Your "sub-activity" can call getIntent()
to retrieve the Intent
used to start it, and from there get at the extras.
精彩评论