FragmentTabHost用法
来源:互联网 发布:什么是嵌入式软件开发 编辑:程序博客网 时间:2024/05/21 13:36
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <FrameLayout android:layout_weight="1" android:id="@+id/content" android:layout_width="wrap_content" android:layout_height="0dp" > </FrameLayout> <android.support.v4.app.FragmentTabHost android:id="@+id/tab" android:layout_width="fill_parent" android:layout_height="wrap_content" /></LinearLayout>
MainActivity
public class MainActivity extends FragmentActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);FragmentTabHost tabHost = (FragmentTabHost) findViewById(R.id.tab);tabHost.setup(this, getSupportFragmentManager(), R.id.content);tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Tab1"), MyFragment.class, null);Bundle b = new Bundle();b.putString("key", "value");tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher)), MyFragment.class, b);}}
MyFragment
package com.example.fragmenttabhost;import android.os.Bundle;import android.support.v4.app.ListFragment;import android.widget.ArrayAdapter;public class MyFragment extends ListFragment{String show1[] = {"1","2","3","4"};String show2[] = {"4","3","2","1"};@Overridepublic void onActivityCreated(Bundle savedInstanceState) {super.onActivityCreated(savedInstanceState);String show[] = null;Bundle bundle = getArguments();if(bundle == null)show = show1;else {show = show2;System.out.println(bundle.get("key"));}setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, show));}}
- FragmentTabHost用法
- FragmentTabHost and Fragment 用法
- FragmentTabHost用法简介
- FragmentTabHost的简单用法
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabHost
- FragmentTabhost
- FragmentTabHost
- FragmentTabHost简单用法,以及Fragment生命周期
- TabHost 和 FragmentTabHost的基本用法
- 【iOS开发】iOS7 兼容及部分细节
- Flash中的动画制作方式?
- jsp页面动态生成验证码
- Windows下打包并在Tomcat7下运行Libreplan(基于Mysql)
- 我的Android进阶之旅------>Android拍照小例子
- FragmentTabHost用法
- 浅谈C++调用C#的DLL程序方法
- java常见算法
- Maven简介
- Windows 下如何安装配置Snort视频教程
- google hacking
- Ajax学习小例
- 图像的RGB颜色空间和HSI空间的转换
- HRBUST 1501 Car Trouble 深搜