底部TabHost
来源:互联网 发布:知乎注册人数 编辑:程序博客网 时间:2024/04/29 02:34
(TabWidget ,FrameLayout 在TabHost内。TabWidget 和FrameLayout 平行的关系)
1.MainActivity
public class MainActivity extends TabActivity {private TabHost tabHost;protected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);//取消标题栏setContentView(R.layout.activity_main);tabHost=getTabHost();addTab("study",R.string.title_study,R.drawable.study,StudyActivity.class);addTab("search",R.string.title_search,R.drawable.search,StudyActivity.class);addTab("game",R.string.title_game,R.drawable.game,StudyActivity.class);addTab("save",R.string.title_save,R.drawable.save,StudyActivity.class);addTab("help",R.string.title_help,R.drawable.help,StudyActivity.class);}@SuppressWarnings("rawtypes")private void addTab(String tag,int title_introduction,int title_icon,Class ActivityClass){tabHost.addTab(tabHost.newTabSpec(tag).setIndicator(getString(title_introduction), getResources().getDrawable(title_icon)).setContent(new Intent(this,ActivityClass)));}public boolean onCreateOptionsMenu(Menu menu){//inflate the menu;this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}
2.activity_main.xml
<RelativeLayout 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" tools:context=".MainActivity" > <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" > </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/tab1" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> <LinearLayout android:id="@+id/tab2" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> <LinearLayout android:id="@+id/tab3" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost></RelativeLayout>
0 0
- 底部TabHost
- 底部TabHost
- android tabhost位于底部
- TabHost的底部实现
- TabHost 添加底部菜单
- TabHost 之实现底部
- TabHost底部导航
- TabHost实现底部菜单
- 实现底部tabhost
- TabHost实现底部栏
- android之实现底部TabHost
- EditText和底部tabhost优化
- android 底部选项卡(TabHost)
- 底部Tab的实现(tabhost)
- TabHost实现底部导航示例
- android之实现底部TabHost
- 解决tabhost底部tab问题
- 底部菜单栏实现之TabHost
- 十六周 文件
- 51nod 1091 线段的重叠
- 第16周阅读程序——4(1)
- activity_main.xml页面放置TabHost控件,用于标题的选择。
- 第十四周项目1.1—排序函数模板(冒泡法排序)
- 底部TabHost
- 十六周 有关文件
- 二叉树的非递归遍历
- 使用配置hadoop中常用的Linux(ubuntu)命令
- Android Studio 签名等小技巧
- 第16周阅读程序——4(2)
- SpringMVC @RequestParam 中文乱码问题解决
- 修改Jenkins的主目录步骤说明
- 二叉树的递归遍历