(1) tag switching interface
I. Code 1. Simplest: FragmentTabHost + FragmentHttp://download.csdn.net/detail/mountain3th/7630123
2. Slightly complicated: TabHost + FragmentHttp://download.csdn.net/detail/mountain3th/7630383
3. Deformation: Button + FragmentHttp://download.csdn.net/detail/mountain3th/7630181
4. upgraded version: added ViewPager to enable horizontal sliding and switching.Http://download.csdn.net/detail/mountain3th/7630189
5. Reusable version: Inherit FragmentTabActivity and implement the abstract method.Http://download.csdn.net/detail/mountain3th/7630355
Ii. Usage Analysis1. If Fragment is used for display or simple interaction, it is the least and simplest to use the first code, but Fragment data Initialization is not allowed because it automatically calls the empty constructor of Fragment.
2. If Fragment needs to be initialized through other data, use the second or third method to redirect through replaceFragment.
3. Add viewpager if you want to have the left-right sliding Function
4. to reuse the version, you only need to implement several abstract methods to achieve tag switching, greatly saving the coding time.
3. layout skills1. Classic Layout
<android.support.v4.app.FragmentTabHost android:id="@+id/fragtab_tabhost_main" android:layout_width="match_parent" android:layout_height="wrap_content" /><FrameLayout android:id="@+id/frame_container_main" android:layout_width="match_parent" android:layout_height="match_parent" />
2. Sliding Layout
<android.support.v4.app.FragmentTabHost android:id="@+id/fragtab_tabhost_main" android:layout_width="match_parent" android:layout_height="wrap_content" > <FrameLayout android:id="@+id/frame_container_main" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0" /></android.support.v4.app.FragmentTabHost><android.support.v4.view.ViewPager android:id="@+id/vp_scroll_latestlist" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
3. Another strange finding is that if the parent control layout in the Fragment layout is RelativeLayout, The EditText in the layout will remain in the previous state.
JavaScript code for tag switching (one page can be used multiple times)
Send me a source code for an email address, which is not difficult.
======================================
The tag is actually that multiple divs are located at the same position and the same size, and different divs are displayed based on the selected tag. Nothing is left. You can write it quickly, however, to be beautiful, you need to work hard.
Automatic Switch of javascript labels
<Li class = "active" name = "kpi01" onclick = "nTabs (this, 0);">
<Span> page 1 </span> </li>
<Li class = "normal" name = "kpi02" onclick = "nTabs (this, 1);">
<Span> page 2 </span> </li>
<Li class = "normal" name = "kpi03" onclick = "nTabs (this, 2);">
<Span> page 3 </span> </li>
<Script>
Var seln = "kpi01 ";
Function nTabs (thisObj, Num ){
If (thisObj. name = seln) return;
ThisObj. className = "active ";
Document. getElementByName ("seln"). className = "normal ";
Seln = thisObj. name;
}
</Script>