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

Android基于API的Tabs3實(shí)現(xiàn)仿優(yōu)酷t(yī)abhost效果實(shí)例

 更新時(shí)間:2015年12月26日 12:26:52   作者:sgx425021234  
這篇文章主要介紹了Android基于API的Tabs3實(shí)現(xiàn)仿優(yōu)酷t(yī)abhost效果,結(jié)合完整實(shí)例形式分析了Android實(shí)現(xiàn)優(yōu)酷界面效果的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Android基于API的Tabs3實(shí)現(xiàn)仿優(yōu)酷t(yī)abhost效果。分享給大家供大家參考,具體如下:

前兩天老師就讓自己寫個(gè)視頻播放器客戶端,這個(gè)是他上課講的一個(gè)小小demo,通過查看安卓API的tabs3,實(shí)現(xiàn)仿優(yōu)酷視頻客戶端的tabhost效果。我的API路徑是D:\android\sdk\samples\android-17\ApiDemos\src\com\example\android\apis\view下的Tabs3,下面是實(shí)現(xiàn)效果:

廢話不多說了,直接上碼:

MainActivity.java

package com.example.video;
import android.os.Bundle;
import android.R.layout;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.widget.TabHost;
public class MainActivity extends TabActivity {
  public TabHost tabHost;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //獲取對象
    tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("myself")
        .setIndicator("個(gè)人中心")
        .setContent(new Intent(this, MySelfActivity.class)));
    tabHost.addTab(tabHost.newTabSpec("myindex")
        .setIndicator("優(yōu)酷首頁")
        .setContent(new Intent(this, MyIndexActivity.class)));
    tabHost.addTab(tabHost.newTabSpec("mycenter")
        .setIndicator("頻道中心")
        .setContent(new Intent(this, MyCenterActivity.class)));
    //指定的當(dāng)前的tab
    //通過索引指定 索引從0開始
    tabHost.setCurrentTab(0); //從零開始
    //通過標(biāo)識來激活
   // tabHost.setCurrentTabByTag("XXX1");
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
}

MyCenterActivity.java

package com.example.video;
import android.app.Activity;
import android.os.Bundle;
public class MyCenterActivity extends Activity{
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mycenter);
  }
}

MyIndexActivity.java

package com.example.video;
import android.app.Activity;
import android.os.Bundle;
public class MyIndexActivity extends Activity{
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_myindex);
  }
}

MySelfActivity.java

package com.example.video;
import android.app.Activity;
import android.os.Bundle;
public class MySelfActivity extends Activity{
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_myself);
  }
}

下面是布局文件:

activity_mycenter.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" >
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="優(yōu)酷中心" />
</RelativeLayout>

activity_myindex.xml

<TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="優(yōu)酷首頁" />

activity_myself.xml

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="個(gè)人首頁" />

當(dāng)然別忘了在清單文件中配置activity

<!-- 配置activity組件 -->
<activity android:name="com.example.video.MyIndexActivity"/>
<activity android:name="com.example.video.MySelfActivity"/>
<activity android:name="com.example.video.MyCenterActivity"/>

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

相關(guān)文章

  • Android使用手勢實(shí)現(xiàn)翻頁效果

    Android使用手勢實(shí)現(xiàn)翻頁效果

    這篇文章主要介紹了Android使用手勢實(shí)現(xiàn)翻頁效果,本程序使用了一個(gè)ViewFlipper組件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-09-09
  • Kotlin學(xué)習(xí)教程之函數(shù)的默認(rèn)參數(shù)

    Kotlin學(xué)習(xí)教程之函數(shù)的默認(rèn)參數(shù)

    這篇文章主要給大家介紹了關(guān)于Kotlin學(xué)習(xí)教程之函數(shù)的默認(rèn)參數(shù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • Android開發(fā)常用經(jīng)典代碼段集錦

    Android開發(fā)常用經(jīng)典代碼段集錦

    這篇文章主要介紹了Android開發(fā)常用經(jīng)典代碼段,涉及Android開發(fā)過程中針對手機(jī)、聯(lián)系人、圖片、存儲卡等的相關(guān)操作技巧,非常簡單實(shí)用,需要的朋友可以參考下
    2016-02-02
  • Android中pendingIntent與Intent的深入分析

    Android中pendingIntent與Intent的深入分析

    這篇文章主要介紹了Android中pendingIntent的深入分析的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • 最新評論