TabActivity横向布局
来源:互联网 发布:比价网源码 编辑:程序博客网 时间:2024/06/05 14:17
系统默认的TabWidget是horizontal的 :
源码一部分
private void initTabWidget() {
setOrientation(LinearLayout.HORIZONTAL);所以我们需要自己改变tabwidget的orientation
TabWidget widget = mHost.getTabWidget();
widget.setOrientation(LinearLayout.VERTICAL);
布局文件
<?xml version="1.0" encoding="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/host"android:layout_width="fill_parent"android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <TabWidget android:id="@android:id/tabs"android:layout_width="180px" android:layout_height="fill_parent"android:background="#ffffffff"android:padding="10dp" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </LinearLayout></TabHost>Activity code
package com.kingkong.testtab;import android.app.ActivityGroup;import android.content.Intent;import android.os.Bundle;import android.widget.LinearLayout;import android.widget.TabHost;import android.widget.TabHost.TabSpec;import android.widget.TabWidget;import android.widget.TextView;public class TestTabActivityActivity extends ActivityGroup {TabHost mHost; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mHost = (TabHost) findViewById(R.id.host); mHost.setup(getLocalActivityManager()); TabWidget widget = mHost.getTabWidget(); widget.setOrientation(LinearLayout.VERTICAL); addTab("jjjjavvva", "java", JavaActivity.class); addTab("aaandroid", "android", AndroidActivity.class); addTab("hhhadoop", "hadoop", HadoopActivity.class); } private void addTab(String indicateText, String tag, Class<?> className) { TextView tab = new TextView(this); tab.setLayoutParams(new LinearLayout.LayoutParams(-1, 50)); tab.setBackgroundResource(R.drawable.tab_bg); tab.setTextColor(0xff000000); tab.setText(indicateText); TabSpec specJava = mHost.newTabSpec(tag); specJava.setIndicator(tab); specJava.setContent(new Intent(this, className)); mHost.addTab(specJava); }}
- TabActivity横向布局
- CSS div横向布局
- div横向布局
- 横向UL布局
- 横向头像布局
- 水果的横向布局
- ExtJS4 表单横向布局
- 横向导航的布局
- 静态Fragment横向布局
- 如何不继承TabActivity实现tabhost布局
- 使用TabHost布局不继承TabActivity
- TabActivity
- TabActivity
- TabActivity
- TabActivity
- android 横向可滑动布局
- android tabHost布局之一 继承TabActivity并以activity布局
- android tabHost布局之一 继承TabActivity并以activity布局
- Android程序打开和关闭输入法,this.getCurrentFocus()有时为空,加try catch
- DirectFB Console Bug调查
- android 腾讯微博分享功能实现及自定义webview认证
- USACO Party Lamps
- sharepoint2010隐藏site workflows
- TabActivity横向布局
- Keil MDK error :L6031U
- 用JQuery解析Json
- zoj 1002 FireNet
- jQuery使用JSON的例子
- IPMI详细介绍
- list.h使用实例
- 网盘地址
- TimerTask的详细使用方法