Android編程實(shí)現(xiàn)在底端顯示選項(xiàng)卡的方法
本文實(shí)例講述了Android編程實(shí)現(xiàn)在底端顯示選項(xiàng)卡的方法。分享給大家供大家參考,具體如下:
1.layout 文件
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@+id/edit_item_tab_host"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp" android:layout_weight="1">
<LinearLayout android:id="@+id/widget_layout_Blue"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3px"
android:paddingRight="3px">
<LinearLayout android:id="@+id/titleLayout_person_check_road_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_person_check_road_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/titleLayout_person_check_road_add"
android:layout_alignTop="@id/titleLayout_person_check_road_add"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_red"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3px" android:paddingRight="3px">
<LinearLayout android:id="@+id/titleLayout_person_check_road_add1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_person_check_road_add1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/titleLayout_person_check_road_add1"
android:layout_alignTop="@id/titleLayout_person_check_road_add1"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_green"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3px" android:paddingRight="3px">
<LinearLayout android:id="@+id/titleLayout_person_check_road_add2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"> </LinearLayout>
<LinearLayout android:id="@+id/layout_person_check_road_add2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/titleLayout_person_check_road_add2"
android:layout_alignTop="@id/titleLayout_person_check_road_add2"
android:orientation="vertical"> </LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_yellow"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3px" android:paddingRight="3px">
<LinearLayout android:id="@+id/titleLayout_person_check_road_add3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"> </LinearLayout>
<LinearLayout android:id="@+id/layout_person_check_road_add3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/titleLayout_person_check_road_add3"
android:layout_alignTop="@id/titleLayout_person_check_road_add3"
android:orientation="vertical"> </LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0" /> </LinearLayout>
</TabHost>
</LinearLayout>
2.Java 文件
import android.app.ActivityGroup;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TabHost;
import android.widget.TextView;
public class TabBottom extends ActivityGroup {
public static TabHost myTabhost;
private LayoutParams title_params = new LayoutParams(120, 50);
private LayoutParams content_params = new LayoutParams(158, 50);
private LinearLayout titleLayout, showViewLayout, titleLayout1,
showViewLayout1, titleLayout2, showViewLayout2, titleLayout3,
showViewLayout3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bottomtab);
myTabhost = (TabHost) findViewById(R.id.edit_item_tab_host);
myTabhost.setup(this.getLocalActivityManager());
titleLayout = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add);
showViewLayout = (LinearLayout) findViewById(R.id.layout_person_check_road_add);
titleLayout1 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add1);
showViewLayout1 = (LinearLayout) findViewById(R.id.layout_person_check_road_add1);
titleLayout2 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add2);
showViewLayout2 = (LinearLayout) findViewById(R.id.layout_person_check_road_add2);
titleLayout3 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add3);
showViewLayout3 = (LinearLayout) findViewById(R.id.layout_person_check_road_add3);
myTabhost.addTab(myTabhost
.newTabSpec("One")
.setIndicator("收件箱",
getResources().getDrawable(R.drawable.icon))
.setContent(R.id.widget_layout_Blue));
myTabhost.addTab(myTabhost
.newTabSpec("Two")
.setIndicator("發(fā)件箱",
getResources().getDrawable(R.drawable.icon))
.setContent(R.id.widget_layout_green));
myTabhost.addTab(myTabhost
.newTabSpec("Three")
.setIndicator("垃圾箱",
getResources().getDrawable(R.drawable.icon))
.setContent(R.id.widget_layout_red));
myTabhost.addTab(myTabhost
.newTabSpec("Four")
.setIndicator("發(fā)送",
getResources().getDrawable(R.drawable.icon))
.setContent(R.id.widget_layout_yellow));
showInLayout();
showInLayout1();
showInLayout2();
showInLayout3();
}
/*
* 填充第一個(gè)選項(xiàng)卡頁面
*/
private void showInLayout() {
for (int i = 0; i < 10; i++) {
String condName = "名稱顯示1";
TextView tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setTextSize(16);
tv.setLayoutParams(title_params);
tv.setText(condName + ":");
titleLayout.addView(tv);
EditText tv1 = new EditText(this);
tv1.setTextSize(16);
tv1.setLayoutParams(content_params);
tv1.setText(condName);
showViewLayout.addView(tv1);
}
}
private void showInLayout1() {
for (int i = 0; i < 10; i++) {
String condName = "名稱顯示2";
TextView tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setTextSize(16);
tv.setLayoutParams(title_params);
tv.setText(condName + ":");
titleLayout1.addView(tv);
TextView tv1 = new TextView(this);
tv1.setTextColor(Color.WHITE);
tv1.setTextSize(16);
tv1.setLayoutParams(content_params);
tv1.setText(condName + ":");
showViewLayout1.addView(tv1);
}
}
private void showInLayout2() {
for (int i = 0; i < 10; i++) {
String condName = "名稱顯示3";
TextView tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setTextSize(16);
tv.setLayoutParams(title_params);
tv.setText(condName + ":");
titleLayout2.addView(tv);
TextView tv1 = new TextView(this);
tv1.setTextColor(Color.WHITE);
tv1.setTextSize(16);
tv1.setLayoutParams(content_params);
tv1.setText(condName + ":");
showViewLayout2.addView(tv1);
}
}
private void showInLayout3() {
for (int i = 0; i < 10; i++) {
String condName = "名稱顯示4";
TextView tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setTextSize(16);
tv.setLayoutParams(title_params);
tv.setText(condName + ":");
titleLayout3.addView(tv);
TextView tv1 = new TextView(this);
tv1.setTextColor(Color.WHITE);
tv1.setTextSize(16);
tv1.setLayoutParams(content_params);
tv1.setText(condName + ":");
showViewLayout3.addView(tv1);
}
}
}
效果如下:


更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android資源操作技巧匯總》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android視圖View技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
- android TabHost(選項(xiàng)卡)的使用方法
- android 選項(xiàng)卡(TabHost)如何放置在屏幕的底部
- Android實(shí)現(xiàn)底部導(dǎo)航欄功能(選項(xiàng)卡)
- Android TabLayout(選項(xiàng)卡布局)簡單用法實(shí)例分析
- Android仿微信底部實(shí)現(xiàn)Tab選項(xiàng)卡切換效果
- Android多個(gè)TAB選項(xiàng)卡切換效果
- Android基于ViewPager Fragment實(shí)現(xiàn)選項(xiàng)卡
- Android利用Fragment實(shí)現(xiàn)Tab選項(xiàng)卡效果
- Android組件TabHost實(shí)現(xiàn)頁面中多個(gè)選項(xiàng)卡切換效果
- Android編程之TabWidget選項(xiàng)卡用法實(shí)例分析
- Android實(shí)現(xiàn)類似網(wǎng)易新聞選項(xiàng)卡動(dòng)態(tài)滑動(dòng)效果
- Android編程實(shí)現(xiàn)自定義Tab選項(xiàng)卡功能示例
相關(guān)文章
Android nativePollOnce函數(shù)解析
這篇文章主要介紹了Android nativePollOnce函數(shù)解析的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-03-03
Android ActionBar完全解析使用官方推薦的最佳導(dǎo)航欄(下)
這篇文章主要介紹了Android ActionBar完全解析使用官方推薦的最佳導(dǎo)航欄(下) ,需要的朋友可以參考下2017-04-04
Android布局控件DrawerLayout實(shí)現(xiàn)完美側(cè)滑效果
這篇文章主要為大家詳細(xì)介紹了Android布局控件DrawerLayout實(shí)現(xiàn)完美側(cè)滑效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-08-08
Android開發(fā)中超好用的正則表達(dá)式工具類RegexUtil完整實(shí)例
這篇文章主要介紹了Android開發(fā)中超好用的正則表達(dá)式工具類RegexUtil,結(jié)合完整實(shí)例形式分析了Android正則表達(dá)式常見操作技巧,包括針對證件號(hào)、銀行賬號(hào)、手機(jī)號(hào)、郵編等的正則判斷相關(guān)操作技巧,需要的朋友可以參考下2017-11-11
android配合viewpager實(shí)現(xiàn)可滑動(dòng)的標(biāo)簽欄示例分享
本文主要介紹了android實(shí)現(xiàn)可滑動(dòng)的標(biāo)簽欄示例,配合viewpager作為標(biāo)簽欄,且可以設(shè)置每頁顯示的標(biāo)簽個(gè)數(shù),超出可滑動(dòng)顯示,需要的朋友可以參考下2014-02-02
Android中TelephonyManager用法實(shí)例
這篇文章主要介紹了Android中TelephonyManager用法,結(jié)合實(shí)例形式分析了TelephonyManager類的功能,使用技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-03-03
Android動(dòng)畫教程之屬性動(dòng)畫詳解
這篇文章主要給大家介紹了關(guān)于Android動(dòng)畫教程之屬性動(dòng)畫的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05

