展会信息港展会大全

Android 将TabHost放在最下方显示
来源:互联网   发布日期:2015-10-03 11:12:20   浏览:2724次  

导读:布局文件:[html]<?xml version="1.0" encoding="utf-8"?><TabHost android:id="@android:id/tabhost" ...

布局文件:

[html]

<?xml version="1.0" encoding="utf-8"?>

<TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout android:orientation="vertical" android:id="@id/ll_main_tab" android:layout_width="fill_parent" android:layout_height="fill_parent">

<FrameLayout android:gravity="center" android:id="@android:id/tabcontent" android:fadingEdge="none" android:fadingEdgeLength="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">

<RelativeLayout android:id="@+id/tabFirst"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">www.2cto.com

<AnalogClock

android:id="@+id/widget31"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true">

</AnalogClock>

</RelativeLayout>

<RelativeLayout android:id="@+id/tabSecond"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

<DigitalClock

android:layout_centerInParent="true"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

</DigitalClock>

</RelativeLayout>

</FrameLayout>

<TabWidget android:id="@android:id/tabs" android:background="@drawable/tab_btn_bg_normal" android:layout_width="fill_parent" android:layout_height="wrap_content" />

</LinearLayout>

</TabHost>

代码区:

[html]

package com.tanghy.tab.activity;

import android.app.TabActivity;

import android.content.Intent;

import android.os.Bundle;

import android.widget.TabHost;

public class MainActivity extends TabActivity {

TabHost tabHost;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

tabHost = getTabHost();

tabHost.addTab(tabHost.newTabSpec("one").setIndicator("aaaa").setContent(R.id.tabFirst));

tabHost.addTab(tabHost.newTabSpec("two").setIndicator("bbb").setContent(R.id.tabSecond));

tabHost.addTab(tabHost.newTabSpec("three").setIndicator("ccc").setContent(new Intent().setClass(this, LogActivity.class)));

tabHost.setCurrentTab(0);

}

}

通过代码我们看出,我们可以使用view的id来设置一个菜单也可以使用intent来设置一个显示界面。。

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港