开发者

How to transfer data with Intents

I am bui开发者_如何学编程lding an application that has 2 classes - Buttons_Class - Display_Class I want to keep them as separate classes. When the user clicks on a button the OnClick routine in the Buttons_Class creates an intent and a bundle and starts the Display_Class activity. This is working fine. The Display_Class gets the information and displays it in a TextView.

What needs to happen next? If the user clicks on a second button, does the Display_Activity need to be recreated? Does a new intend need to be created? How does the information go from one activity to the next every time the user clicks on a button. Any examples will be greatly appreciated.


If the user clicks on a second button, does the Display_Activity need to be recreated?

When you call startActivity(), by default, it creates a new instance of the activity. You can control that with flags on the Intent if you want, such as FLAG_ACTIVITY_REORDER_TO_FRONT.

Does a new intend need to be created?

If you are starting a different activity, yes. If you are starting another copy of Display_Activity, perhaps not.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜