欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android編程實現(xiàn)將tab選項卡放在屏幕底部的方法

 更新時間:2017年03月01日 10:23:48   作者:android小豬  
這篇文章主要介紹了Android編程實現(xiàn)將tab選項卡放在屏幕底部的方法,涉及Android界面布局、tab設置及權限控制相關操作技巧,需要的朋友可以參考下

本文實例講述了Android編程實現(xiàn)將tab選項卡放在屏幕底部的方法。分享給大家供大家參考,具體如下:

今天寫Tab的時候由于TAB的跳轉(zhuǎn)問題去查資料,倒反而發(fā)現(xiàn)更有趣的問題,就是如何將TAB放置在屏幕的底端。有點類似IPhone里的布局了,呵呵~(其實后來發(fā)現(xiàn)這個應該不是用TAB做的,而是ButtonBar做出來的吧,或者是他重寫了TAB?總之不是簡單地將TAB放置底端了)。

要放置底端,那么Android自帶的例程是不可以做到的(例程參看development-ApiDemo)。先需要寫一個xml的layout文檔,命名為bottomtab.xml。

<?xml version="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:androidLinearLayoutxmlns: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">
      <FrameLayoutandroid:idFrameLayoutandroid:id="@android:id/tabcontent"
        android:layout_width="fill_parent"android:layout_height="wrap_content"
        android:padding="5dp" android:layout_weight="1"/>
      <TabWidget android:id="@android:id/tabs"
        android:layout_width="fill_parent"android:layout_height="wrap_content"
        android:layout_weight="0" />
    </LinearLayout>
  </TabHost>
</LinearLayout>

然后以下就是完整的代碼了:

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class TestTab extends ActivityGroup {
  publicstatic TabHost tab_host;
  @Override
  protectedvoid onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bottomtab);
    tab_host = (TabHost) findViewById(R.id.edit_item_tab_host);
    tab_host.setup(this.getLocalActivityManager());
    TabSpec ts1 = tab_host.newTabSpec("TAB_WEATHER");
    ts1.setIndicator("Weather");
    ts1.setContent(new Intent(this, Weather.class));
    tab_host.addTab(ts1);
    TabSpec ts2 = tab_host.newTabSpec("TAB_MAIL");
    ts2.setIndicator("Mail");
    ts2.setContent(new Intent(this, MailSend.class));
    tab_host.addTab(ts2);
    TabSpec ts3 = tab_host.newTabSpec("TAB_JUMP");
    ts3.setIndicator("Jump");
    ts3.setContent(new Intent(this, TabJump.class));
    tab_host.addTab(ts3);
    tab_host.setCurrentTab(0);
  }
}

而關于頁面的跳轉(zhuǎn),就是:

TestTab.tabHost.setCurrentTab(0);

如此這般,就形成了下面的這個東西,其實還沒有放在上面好看。。。所以也證實了上面那個應用不是簡單地放置TAB在底端了。有機會還是再看看ButtonBar了。

注意:Weather.class 等Activity要在 在AndroidMenifest.xml添加聲明

在 application tag之間加上如下代碼:

</activity>
   <activityandroid:nameactivityandroid:name=".Weather">
</activity>
   <activityandroid:nameactivityandroid:name=".MailSend">
</activity>
   <activityandroid:nameactivityandroid:name=".TabJump">
</activity>

PS:關于AndroidManifest.xml文件相關屬性功能可參考本站在線工具:

Android Manifest功能與權限描述大全:
http://tools.jb51.net/table/AndroidManifest

更多關于Android相關內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結》、《Android視圖View技巧總結》、《Android布局layout技巧總結》及《Android控件用法總結

希望本文所述對大家Android程序設計有所幫助。

相關文章

  • Android ViewPager的MVP架構搭建過程

    Android ViewPager的MVP架構搭建過程

    本文主要介紹了ViewPager在Android中的作用以及使用場景,如引導頁、圖片瀏覽器、新聞或文章內(nèi)容的多標簽頁等,同時,還詳細闡述了如何通過MVP架構來搭建ViewPager,將視圖和邏輯進行解耦,提高代碼的可測試性、可復用性,使代碼結構更清晰且易于擴展功能
    2024-10-10
  • Flutter 插件url_launcher簡介

    Flutter 插件url_launcher簡介

    最近項目需求是打開一個連接跳轉(zhuǎn)到安卓或蘋果默認的瀏覽器。雖然開始一個簡單的要求,其中的一個細節(jié)就是執(zhí)行打開網(wǎng)頁這一操作后,不能看上去像在應用內(nèi)部打開,看上去要在應用外部打開,今天小編給大家介紹Flutter 插件url_launcher的相關知識,感興趣的朋友一起看看吧
    2020-04-04
  • 通過Android trace文件分析死鎖ANR實例過程

    通過Android trace文件分析死鎖ANR實例過程

    遇到ANR(Application Not Responding)是比較常見的問題,產(chǎn)生ANR的原因有很多,比如CPU使用過高、事件沒有得到及時的響應、死鎖等,下面將通過一次因為死鎖導致的ANR問題,來說明如何通過trace文件分析ANR問題
    2013-06-06
  • Android中的windowSoftInputMode屬性詳解

    Android中的windowSoftInputMode屬性詳解

    這篇文章主要介紹了Android中的windowSoftInputMode屬性詳解,本文對windowSoftInputMode的9個屬性做了詳細總結,需要的朋友可以參考下
    2014-10-10
  • Android如何在原生App中嵌入Flutter

    Android如何在原生App中嵌入Flutter

    這篇文章主要介紹了Android如何在原生App中嵌入Flutter,幫助大家更好的理解和學習Android開發(fā),感興趣的朋友可以了解下
    2021-03-03
  • Android中的Choreographer工作原理解析

    Android中的Choreographer工作原理解析

    Choreographer作為Android系統(tǒng)中重要的組件,負責協(xié)調(diào)App進程的UI渲染與SurfaceFlinger進程的數(shù)據(jù)合成,本文詳細分析了Choreographer的創(chuàng)建流程、VSYNC信號的調(diào)度和處理機制,揭示了其在UI渲染過程中的核心作用
    2024-10-10
  • Android實現(xiàn)自定義滑動刻度尺方法示例

    Android實現(xiàn)自定義滑動刻度尺方法示例

    這篇文章主要給大家介紹了關于Android實現(xiàn)自定義滑動刻度尺的相關資料,文中通過示例代碼介紹的非常詳細,對各位Android開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-04-04
  • Android使用文件進行IPC

    Android使用文件進行IPC

    這篇文章主要為大家詳細介紹了Android使用文件進行IPC,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • android Tween Animation屬性設置方法實例

    android Tween Animation屬性設置方法實例

    在Android開發(fā)中,Animation是用來給控件制作效果的,本文介紹二種實現(xiàn)方法
    2013-11-11
  • android 手機SD卡讀寫操作(以txt文本為例)實現(xiàn)步驟

    android 手機SD卡讀寫操作(以txt文本為例)實現(xiàn)步驟

    要完成SD卡讀寫操作首先對manifest注冊SD卡讀寫權限其次是創(chuàng)建一個對SD卡中文件讀寫的類寫一個用于檢測讀寫功能的的布局然后就是UI的類了,感興趣的朋友可以參考下,希望可以幫助到你
    2013-02-02

最新評論