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

Android仿新浪微博分頁管理界面(3)

 更新時間:2016年11月21日 11:01:27   作者:DeMon輝  
這篇文章主要為大家詳細(xì)介紹了Android仿新浪微博分頁管理界面,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android仿新浪微博分頁管理界面的具體代碼,供大家參考,具體內(nèi)容如下

多個activity分頁管理,為了方便獲取上下文,采用繼承TabActivity的傳統(tǒng)方法。

大致思路:使用RadioGroup點(diǎn)擊觸發(fā)不同的選卡項(xiàng),選卡項(xiàng)綁定不同的activiity,進(jìn)而進(jìn)行分頁管理。詳解見注解。

/**
 * 主Activity
 * 通過點(diǎn)擊RadioGroup下的RadioButton來切換不同界面
 * Created by D&LL on 2016/7/20.
 */
public class MainActivity extends TabActivity {
 //定義TabHost對象
 private TabHost tabHost;
 //定義RadioGroup對象
 private RadioGroup radioGroup;
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.tab_layout);
  initView();
  initData();
 }
 /**
  * 初始化組件
  */
 private void initView() {
  //實(shí)例化TabHost,得到TabHost對象
  tabHost = getTabHost();

  //得到Activity的個數(shù)
  int count = Constant.ConValue.mTabClassArray.length;

  for (int i = 0; i < count; i++) {
   //為每一個Tab按鈕設(shè)置圖標(biāo)、文字和內(nèi)容
   TabSpec tabSpec = tabHost.newTabSpec(Constant.ConValue.mTextviewArray[i])
     .setIndicator(Constant.ConValue.mTextviewArray[i]).setContent(getTabItemIntent(i));
   //將Tab按鈕添加進(jìn)Tab選項(xiàng)卡中
   tabHost.addTab(tabSpec);
  }
  //實(shí)例化RadioGroup
  radioGroup = (RadioGroup) findViewById(R.id.main_radiogroup);
 }
 /**
  * 初始化組件
  */
 private void initData() {
  // 給radioGroup設(shè)置監(jiān)聽事件
  radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
   public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (checkedId) {
     case R.id.RadioButton0:
      tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[0]);
      break;
     case R.id.RadioButton1:
      tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[1]);
      break;
     case R.id.RadioButton2:
      tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[2]);
      break;
     case R.id.RadioButton3:
      tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[3]);
      break;
     case R.id.RadioButton4:
      tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[4]);
      break;
    }
   }
  });
  ((RadioButton) radioGroup.getChildAt(0)).toggle();
 }
 /**
  * 給Tab選項(xiàng)卡設(shè)置內(nèi)容(每個內(nèi)容都是一個Activity)
  */
 private Intent getTabItemIntent(int index) {
  Intent intent = new Intent(this, Constant.ConValue.mTabClassArray[index]);
  return intent;
 }
}

MainActivity布局文件tab_layout.xml. TabHost布局,添加一個TabWidget用于顯示activity,下面是一個RadioGroup顯示切換activity的按鈕菜單。

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">
  <FrameLayout
   android:id="@android:id/tabcontent"
   android:layout_width="fill_parent"
   android:layout_height="0.0dip"
   android:layout_weight="1.0"/>
  <TabWidget
   android:id="@android:id/tabs"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_weight="0.0"
   android:visibility="gone"/>
  <RadioGroup
   android:id="@+id/main_radiogroup"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_gravity="bottom"
   android:background="@drawable/tab_widget_background"
   android:gravity="center_vertical"
   android:orientation="horizontal"
   android:padding="2dip">
   <RadioButton
    android:id="@+id/RadioButton0"
    style="@style/tab_item_background"
    android:drawableTop="@drawable/tab_home"
    android:text="主頁"
    android:textColor="#ffffff"/>
   <RadioButton
    android:id="@+id/RadioButton1"
    style="@style/tab_item_background"
    android:drawableTop="@drawable/tab_msg"
    android:text="評論"
    android:textColor="#ffffff"/>
   <RadioButton
    android:id="@+id/RadioButton2"
    style="@style/tab_item_background"
    android:drawableTop="@drawable/tab_write"
    android:text="發(fā)微博"
    android:textColor="#ffffff"/>
   <RadioButton
    android:id="@+id/RadioButton3"
    style="@style/tab_item_background"
    android:drawableTop="@drawable/tab_me"
    android:text="用戶信息"
    android:textColor="#ffffff"/>
   <RadioButton
    android:id="@+id/RadioButton4"
    style="@style/tab_item_background"
    android:drawableTop="@drawable/tab_more"
    android:text="更多"
    android:textColor="#ffffff"/>
  </RadioGroup>
 </LinearLayout>
</TabHost>

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android實(shí)現(xiàn)長按圓環(huán)動畫View效果的思路代碼

    Android實(shí)現(xiàn)長按圓環(huán)動畫View效果的思路代碼

    這篇文章主要介紹了Android實(shí)現(xiàn)長按圓環(huán)動畫View效果,本文給大家分享實(shí)現(xiàn)思路,通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-09-09
  • Android自定義漸變式炫酷ListView下拉刷新動畫

    Android自定義漸變式炫酷ListView下拉刷新動畫

    這篇文章主要為大家詳細(xì)介紹了Android自定義漸變式炫酷ListView下拉刷新動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • Android實(shí)現(xiàn)單行標(biāo)簽流式布局

    Android實(shí)現(xiàn)單行標(biāo)簽流式布局

    這篇文章主要為大家詳細(xì)介紹了Android單行標(biāo)簽流式布局,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • 淺析Android手機(jī)衛(wèi)士讀取聯(lián)系人

    淺析Android手機(jī)衛(wèi)士讀取聯(lián)系人

    這篇文章主要介紹了淺析Android手機(jī)衛(wèi)士讀取聯(lián)系人的相關(guān)內(nèi)容,通過getContentResolver()方法獲取獲取ContentResolver內(nèi)容解析器對象,對android手機(jī)衛(wèi)士讀取聯(lián)系人相關(guān)知識感興趣的朋友參考下吧
    2016-04-04
  • Android開發(fā)Kotlin?DSL使用技巧掌握

    Android開發(fā)Kotlin?DSL使用技巧掌握

    這篇文章主要為大家介紹了Android開發(fā)Kotlin?DSL使用技巧的掌握,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • android之BroadcastReceiver應(yīng)用詳解

    android之BroadcastReceiver應(yīng)用詳解

    這篇文章主要介紹了android之BroadcastReceiver應(yīng)用詳解,BroadcastReceiver也就是“廣播接收者”的意思,顧名思義,它就是用來接收來自系統(tǒng)和應(yīng)用中的廣播。有興趣的可以了解一下。
    2016-12-12
  • android中view手勢滑動沖突的解決方法

    android中view手勢滑動沖突的解決方法

    本篇文章主要介紹了android中view手勢滑動沖突的解決方法,主要解決方法有兩種,外部和內(nèi)部攔截。有需要的可以參考下。
    2016-11-11
  • 分享Android中Toast的自定義使用

    分享Android中Toast的自定義使用

    Android中的Toast是一種簡易的消息提示框,toast提示框不能被用戶點(diǎn)擊,toast會根據(jù)用戶設(shè)置的顯示時間后自動消失。本文將介紹Toast的自定義使用,下面一起來看看吧。
    2016-08-08
  • Android AS創(chuàng)建自定義布局案例詳解

    Android AS創(chuàng)建自定義布局案例詳解

    這篇文章主要介紹了Android AS創(chuàng)建自定義布局案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • Android播放音樂案例分享

    Android播放音樂案例分享

    這篇文章主要為大家分享了Android播放音樂案例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-09-09

最新評論