Android: enables activity redirection within a single tab.

Source: Internet
Author: User

This does not mean the switch of the tab, but the internal jump in a single tab.

For example, there is a tabwidget, for example, there are four activity A, B, C, and D on it, and then there is a button on a to redirect the implementation to activityx. IfCodeFor example:
Intent intent = new intent (Aactivity. This, xxactivity. Class );

Startactivity (intent );

Finish ();

After the command is executed, it only enters activityx, but the following tabwidget disappears.

The effect we want is to switch to activityx, while maintaining the following tabwidget, which is similar to the navigation function in uitarbar of the iPhone.

 

Online distress has a lot of results, but the solution is also messy.

 

Solution 1: Activity + tabhost + activitygroup

HoweverActivitygroupGoogle has been deprecated, and its official recommendation is to use fragment, so I have not tried this method.

ActivitygroupFor more information, see

Partition activity in Android tabhost

 

Solution 2: fragment + tabhost + fragmentactivity

FragmentIs only after 3.0 features, but before this SDK can be added extension package (android-support-v4) to achieve its function.

Fragement use can refer to http://marshal.easymorse.com /? S = Fragment

 

Mhost. addtab (mhost. newtabspec ("Tab1"). Setindicator ("Tab1"). Setcontent (NewIntent (maintabactivity.This, Fragmentactivity1.Class)));

In this way, the tab is a fragemntactivity, and fragment can be added to the fragemntactivity for management.

For details about how to implement the tab, refer

Android tabhost with fragmentactivity

 

Iii. Conjecture: fragmentactivity

Previously, fragment was used to implement a master-Details interface, similar to the uisplitview in the iPhone. Its principle is to divide the fragmentactivity interface into two pieces, and then add and manage fragment to and from the left. On the right side of the page, you can also jump to the activity. As a result, if you divide the fragmentactivity view into the upper and lower two parts, the following is a tab form!

Try to find time ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.