开发者

Pass custom parameters to subactivity

开发者 https://www.devze.com 2023-03-01 15:13 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消