亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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

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

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("個人中心")
        .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)));
    //指定的當前的tab
    //通過索引指定 索引從0開始
    tabHost.setCurrentTab(0); //從零開始
    //通過標識來激活
   // 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="個人首頁" />

當然別忘了在清單文件中配置activity

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

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

相關文章

  • Android中系統(tǒng)默認輸入法設置的方法(輸入法的顯示和隱藏)

    Android中系統(tǒng)默認輸入法設置的方法(輸入法的顯示和隱藏)

    這篇文章主要介紹了Android中系統(tǒng)默認輸入法設置的方法(輸入法的顯示和隱藏)的相關資料,需要的朋友可以參考下
    2016-01-01
  • Android應用開發(fā)中RecyclerView組件使用入門教程

    Android應用開發(fā)中RecyclerView組件使用入門教程

    這篇文章主要介紹了Android應用開發(fā)中RecyclerView組件使用的入門教程,RecyclerView主要針對安卓5.0以上的material design開發(fā)提供支持,需要的朋友可以參考下
    2016-02-02
  • Android xml實現animation的4種動畫效果實例代碼

    Android xml實現animation的4種動畫效果實例代碼

    在Android應用程序,使用動畫效果,能帶給用戶更好的感覺,做動畫可以通過XML或Android代碼來實現。本文給大家介紹Android xml實現animation的4種動畫效果實例代碼,一起看看吧
    2016-05-05
  • AndroidQ 沙箱適配多媒體文件(小結)

    AndroidQ 沙箱適配多媒體文件(小結)

    這篇文章主要介紹了AndroidQ 沙箱適配多媒體文件(小結),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-11-11
  • Android普通對話框用法實例分析

    Android普通對話框用法實例分析

    這篇文章主要介紹了Android普通對話框用法,以實例形式較為詳細的分析了Android對話框的創(chuàng)建技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-09-09
  • React-Native之Android(6.0及以上)權限申請詳解

    React-Native之Android(6.0及以上)權限申請詳解

    這篇文章主要介紹了React-Native之Android(6.0及以上)權限申請詳解,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • Android使用手勢實現翻頁效果

    Android使用手勢實現翻頁效果

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

    Kotlin學習教程之函數的默認參數

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

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

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

    Android中pendingIntent與Intent的深入分析

    這篇文章主要介紹了Android中pendingIntent的深入分析的相關資料,需要的朋友可以參考下
    2017-04-04

最新評論