<?xml version="1.0" encoding="utf-8"?>
<TabHost android:id="@android:id/tabhost"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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">
</FrameLayout>
</LinearLayout>
</TabHost>
TabHost tabHost=this.getTabHost();
public TabHost.TabSpec newTabSpec (String tag)
public void addTab (TabHost.TabSpec tabSpec)
public void clearAllTabs () public int getCurrentTab ()
public void setCurrentTab (int index)
public void setCurrentTabByTag (String tag)
public void setOnTabChangedListener (TabHost.OnTabChangeListener l)
public String getTag () public TabHost.TabSpec setContent public TabHost.TabSpec setIndicator
setIndicator (CharSequence label)
setIndicator (CharSequence label, Drawable icon)
setIndicator (View view)
setContent(int viewId)
package com.zhanglong.music;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TabHost;
public class MainActivity extends TabActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, ListActivity.class);
spec = tabHost.newTabSpec("音乐").setIndicator("音乐",
res.getDrawable(R.drawable.item))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ArtistsActivity.class);
spec = tabHost.newTabSpec("艺术家").setIndicator("艺术家",
res.getDrawable(R.drawable.artist))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("专辑").setIndicator("专辑",
res.getDrawable(R.drawable.album))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SongsActivity.class);
spec = tabHost.newTabSpec("最近播放").setIndicator("最近播放",
res.getDrawable(R.drawable.album))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有