Implementation of activity processing return results in Android

We all have such an experience when shopping online. When confirming the order and selecting the consignee and address, we will jump to the interface of all receiving information (including receiving address and consignee) stored in the website for us to choose. Once we click one of the information, we will automatically jump to the order submission interface, At this time, the receipt information has changed to the previously selected receipt information

In order to realize this function, Android provides a mechanism to jump to other activities and then return. You can accept the values returned by other activities without starting a new current activity; In the following example, two activities are created, in which "your zodiac" is prompted in mainactivity, and then click textview "your zodiac" to start main2activity. Select the zodiac in main2activity, and then return the data previously selected in main2activity to mainactivity as it is when returning to mainactivity. The implementation effect is shown in the figure below:

The core implementation steps are as follows:

(1) Set the startup activity with the result requestcode in mainactivity

(2) Set the method to process the returned results in mainactivity

(3) Set the return result in main2activity

The specific layout and function implementation code are as follows:

(1) Activity in layout_ Main.xml homepage layout:

(2) Activity in layout_ Main2.xml page 2 layout:

(3) Mainactivity.java implementation code of homepage layout in Java:

(4) The second page layout in Java main2activity.java implementation code:

The above is the implementation method of activity processing return results in Android introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>