最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android簡(jiǎn)單實(shí)現(xiàn)屏幕下方Tab菜單的方法

 更新時(shí)間:2016年08月18日 10:38:04   作者:與時(shí)俱進(jìn)  
這篇文章主要介紹了Android簡(jiǎn)單實(shí)現(xiàn)屏幕下方Tab菜單的方法,簡(jiǎn)單分析了Android實(shí)現(xiàn)tab菜單所涉及的界面布局及功能相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android簡(jiǎn)單實(shí)現(xiàn)屏幕下方Tab菜單的方法。分享給大家供大家參考,具體如下:

看到很多熱門的Android程序(如:新浪微博、騰訊微博、京東商城、淘寶、當(dāng)當(dāng)?shù)鹊龋┦褂眠x項(xiàng)卡風(fēng)格作為程序界面的主框架結(jié)構(gòu),而Android的選項(xiàng)卡控件默認(rèn)是按鈕在上方的。我在網(wǎng)上看到有多種實(shí)現(xiàn)方法,這里提供一種個(gè)人覺(jué)得比較簡(jiǎn)單的。由于我對(duì)Android開(kāi)發(fā)所知甚少,方法的優(yōu)劣目前不好評(píng)價(jià),歡迎各位提供更好的思路。

主要原理:設(shè)置 TabWidget 控件的 android:layout_alignParentBottom="true" 實(shí)現(xiàn)。

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost android:id="@+id/tabhost" xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <TabWidget android:id="@android:id/tabs"
      android:layout_width="fill_parent" android:layout_height="wrap_content"
      android:layout_alignParentBottom="true" />
    <FrameLayout android:id="@android:id/tabcontent"
      android:layout_width="fill_parent" android:layout_height="fill_parent">
      <LinearLayout android:id="@+id/tab1"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        androidrientation="vertical">
        <TextView android:id="@+id/view1" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="@string/textView_1" />
      </LinearLayout>
      <LinearLayout android:id="@+id/tab2"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        androidrientation="vertical">
        <TextView android:id="@+id/view2" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="@string/textView_2" />
      </LinearLayout>
      <LinearLayout android:id="@+id/tab3"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        androidrientation="vertical">
        <TextView android:id="@+id/view3" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="@string/textView_3" />
      </LinearLayout>
      <LinearLayout android:id="@+id/tab4"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        androidrientation="vertical">
        <TextView android:id="@+id/view4" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="@string/textView_4" />
      </LinearLayout>
    </FrameLayout>
  </RelativeLayout>
</TabHost>

zhnews.java:

package net.zhnews.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
public class zhnews extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    setTitle("珠海新聞網(wǎng)Android客戶端");
    TabHost tabs = (TabHost) findViewById(R.id.tabhost);
    tabs.setup();
    TabHost.TabSpec spec = tabs.newTabSpec("tab1");
    spec.setContent(R.id.tab1);
    spec.setIndicator("新聞");
    tabs.addTab(spec);
    spec = tabs.newTabSpec("tab2");
    spec.setContent(R.id.tab2);
    spec.setIndicator("搜聯(lián)社");
    tabs.addTab(spec);
    spec = tabs.newTabSpec("tab3");
    spec.setContent(R.id.tab3);
    spec.setIndicator("影像");
    tabs.addTab(spec);
    spec = tabs.newTabSpec("tab4");
    spec.setContent(R.id.tab4);
    spec.setIndicator("設(shè)置");
    tabs.addTab(spec);
    tabs.setCurrentTab(0);
  }
}

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android開(kāi)發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android操作SQLite數(shù)據(jù)庫(kù)技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫(kù)操作技巧總結(jié)》、《Android文件操作技巧匯總》、《Android編程開(kāi)發(fā)之SD卡操作方法匯總》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

峡江县| 广灵县| 尚义县| 辉南县| 八宿县| 平昌县| 乌海市| 永川市| 正镶白旗| 深泽县| 阜南县| 湄潭县| 化德县| 株洲县| 会宁县| 扎兰屯市| 沛县| 林甸县| 栖霞市| 闸北区| 武强县| 长岭县| 车致| 霍州市| 贵南县| 石河子市| 延寿县| 峨边| 苍溪县| 大悟县| 太仆寺旗| 玛沁县| 偃师市| 普兰店市| 木兰县| 中西区| 扎囊县| 即墨市| 锡林浩特市| 阳新县| 新津县|