开发者

Pass custom parameters to subactivity

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜