国产一区二区精品在线_午夜精品视频_亚洲国产高清高潮精品美女_久久久91_午夜精品视频_久久久久亚洲一区二区三区

Android之ActivityGroup實現Tab分頁標簽

來源:網絡

點擊:2234

A+ A-

所屬頻道:新聞中心

關鍵詞: Android,ActivityGroup,Tab分頁

      很多客戶端軟件和瀏覽器軟件都喜歡用Tab分頁標簽來管理內容,除了可以用TabHost控件,還可以用ImageButton + ActivityGroup實現Tab分頁標簽。使用ImageButton + ActivityGroup實現Tab分頁標簽,主要是把一個Sub Activity(子Activity)的Window作為View添加到ActivityGroup所指定的容器中,本文使用LinearLayout作為容器裝載Sub Activity。

      接下來貼出本例運行的效果圖:

    接下來貼出本例運行的效果圖

     

      以下是切換時Sub Activity的生存周期的狀態變化:

    切換時Sub Activity的生存周期的狀態變化

     

      從subActivity1切換到subActivity2的時候,會徹底釋放subActivity1的資源。

      主Activity的main.xml的源碼如下:

      view plaincopy to clipboardprint?

      《?xml version=“1.0” encoding=“utf-8”?》

      《LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

      android:orientation=“vertical” android:layout_width=“fill_parent”

      android:layout_height=“fill_parent”》

      《LinearLayout android:id=“@+id/LinearLayout01”

      android:layout_height=“wrap_content” android:layout_width=“fill_parent”》

      《ImageButton android:layout_width=“wrap_content”

      android:layout_height=“wrap_content” android:id=“@+id/ibtnTab1”

      android:background=“@drawable/png1298”》《/ImageButton》

      《ImageButton android:layout_width=“wrap_content”

      android:layout_height=“wrap_content” android:id=“@+id/ibtnTab2”

      android:background=“@drawable/png1292”》《/ImageButton》

      《/LinearLayout》

      《LinearLayout android:id=“@+id/LinearLayout02”

      android:layout_width=“fill_parent” android:layout_height=“fill_parent”》《/LinearLayout》

      《/LinearLayout》

      《?xml version=“1.0” encoding=“utf-8”?》

      《LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

      android:orientation=“vertical” android:layout_width=“fill_parent”

      android:layout_height=“fill_parent”》

      《LinearLayout android:id=“@+id/LinearLayout01”

      android:layout_height=“wrap_content” android:layout_width=“fill_parent”》

      《ImageButton android:layout_width=“wrap_content”

      android:layout_height=“wrap_content” android:id=“@+id/ibtnTab1”

      android:background=“@drawable/png1298”》《/ImageButton》

      《ImageButton android:layout_width=“wrap_content”

      android:layout_height=“wrap_content” android:id=“@+id/ibtnTab2”

      android:background=“@drawable/png1292”》《/ImageButton》

      《/LinearLayout》

      《LinearLayout android:id=“@+id/LinearLayout02”

      android:layout_width=“fill_parent” android:layout_height=“fill_parent”》《/LinearLayout》

      《/LinearLayout》

      Sub Activity的XML源碼(listview.xml)如下:

      view plaincopy to clipboardprint?

      《?xml version=“1.0” encoding=“utf-8”?》

      《LinearLayout android:id=“@+id/LinearLayout01”

      xmlns:android=“http://schemas.android.com/apk/res/android”

      android:layout_width=“fill_parent” android:layout_height=“fill_parent”》

      《ListView android:id=“@+id/MyListView” android:layout_width=“fill_parent”

      android:layout_height=“fill_parent”》

      《/ListView》

      《/LinearLayout》

      《?xml version=“1.0” encoding=“utf-8”?》

      《LinearLayout android:id=“@+id/LinearLayout01”

      xmlns:android=“http://schemas.android.com/apk/res/android”

      android:layout_width=“fill_parent” android:layout_height=“fill_parent”》

      《ListView android:id=“@+id/MyListView” android:layout_width=“fill_parent”

      android:layout_height=“fill_parent”》

      《/ListView》

      《/LinearLayout》

     

      testActivityGroup.java源碼如下:

      view plaincopy to clipboardprint?

      package com.testActivityGroup;

      import android.app.ActivityGroup;

      import android.content.Intent;

      import android.os.Bundle;

      import android.view.View;

      import android.view.Window;

      import android.widget.ImageButton;

      import android.widget.LinearLayout;

      import android.widget.ListView;

      public class testActivityGroup extends ActivityGroup {

      /** Called when the activity is first created. */

      LinearLayout container;//裝載sub Activity的容器

      ImageButton ibtnTab1,ibtnTab2;

      @Override

      public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.main);

      container = (LinearLayout) findViewById(R.id.LinearLayout02);

      ibtnTab1=(ImageButton)this.findViewById(R.id.ibtnTab1);

      ibtnTab1.setOnClickListener(new ClickEvent());

      ibtnTab2=(ImageButton)this.findViewById(R.id.ibtnTab2);

      ibtnTab2.setOnClickListener(new ClickEvent());

      }

      class ClickEvent implements View.OnClickListener{

      @Override

      public void onClick(View v) {

      container.removeAllViews();

      Intent intent=new Intent(testActivityGroup.this, subActivity.class);

      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

      String[] str=new String[12];

      if(v==ibtnTab1)

      {

      for(int i=0;i《str.length;i++)

      str[i]=“單選”+String.valueOf(i);

      intent.putExtra(“Name”, “subActivity1”);

      intent.putExtra(“Strings”, str);

      intent.putExtra(“ChoiceMode”, ListView.CHOICE_MODE_SINGLE);//通過參數設置列表式樣

      }

      else if(v==ibtnTab2)

      {

      for(int i=0;i《str.length;i++)

      str[i]=“復選”+String.valueOf(i);

      intent.putExtra(“Name”, “subActivity2”);

      intent.putExtra(“Strings”, str);

      intent.putExtra(“ChoiceMode”, ListView.CHOICE_MODE_MULTIPLE);//通過參數設置列表式樣

      }

      Window subActivity=getLocalActivityManager().startActivity(“subActivity”,intent);

      container.addView(subActivity.getDecorView());

      }

      }

      }

      package com.testActivityGroup;

      import android.app.ActivityGroup;

      import android.content.Intent;

      import android.os.Bundle;

      import android.view.View;

      import android.view.Window;

      import android.widget.ImageButton;

      import android.widget.LinearLayout;

      import android.widget.ListView;

      public class testActivityGroup extends ActivityGroup {

      /** Called when the activity is first created. */

      LinearLayout container;//裝載sub Activity的容器

      ImageButton ibtnTab1,ibtnTab2;

      @Override

      public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.main);

      container = (LinearLayout) findViewById(R.id.LinearLayout02);

      ibtnTab1=(ImageButton)this.findViewById(R.id.ibtnTab1);

      ibtnTab1.setOnClickListener(new ClickEvent());

      ibtnTab2=(ImageButton)this.findViewById(R.id.ibtnTab2);

      ibtnTab2.setOnClickListener(new ClickEvent());

      }

      class ClickEvent implements View.OnClickListener{

      @Override

      public void onClick(View v) {

      container.removeAllViews();

      Intent intent=new Intent(testActivityGroup.this, subActivity.class);

      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

      String[] str=new String[12];

      if(v==ibtnTab1)

      {

      for(int i=0;i《str.length;i++)

      str[i]=“單選”+String.valueOf(i);

      intent.putExtra(“Name”, “subActivity1”);

      intent.putExtra(“Strings”, str);

      intent.putExtra(“ChoiceMode”, ListView.CHOICE_MODE_SINGLE);//通過參數設置列表式樣

      }

      else if(v==ibtnTab2)

      {

      for(int i=0;i《str.length;i++)

      str[i]=“復選”+String.valueOf(i);

      intent.putExtra(“Name”, “subActivity2”);

      intent.putExtra(“Strings”, str);

      intent.putExtra(“ChoiceMode”, ListView.CHOICE_MODE_MULTIPLE);//通過參數設置列表式樣

      }

      Window subActivity=getLocalActivityManager().startActivity(“subActivity”,intent);

      container.addView(subActivity.getDecorView());

      }

      }

      }

     

      subActivity.java源碼如下:

      view plaincopy to clipboardprint?

      package com.testActivityGroup;

      import android.app.Activity;

      import android.os.Bundle;

      import android.util.Log;

      import android.widget.ArrayAdapter;

      import android.widget.ListView;

      public class subActivity extends Activity {

      String name;

      public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.listview);

      // 讀取列表內容

      name = this.getIntent().getStringExtra(“Name”);

      String[] str = this.getIntent().getStringArrayExtra(“Strings”);

      int choiceMode = this.getIntent().getIntExtra(“ChoiceMode”,

      ListView.CHOICE_MODE_NONE);

      ListView listView = (ListView) findViewById(R.id.MyListView);

      // 設置列表的式樣

      int itemID = android.R.layout.simple_list_item_1;

      if (choiceMode == ListView.CHOICE_MODE_MULTIPLE)// 主Activity要求多選

      itemID = android.R.layout.simple_list_item_multiple_choice;

      else if (choiceMode == ListView.CHOICE_MODE_SINGLE)// 主Activity要求單選

      itemID = android.R.layout.simple_list_item_single_choice;

      ArrayAdapter《String》 arrayAdapter = new ArrayAdapter《String》(this,

      itemID, str);

      listView.setAdapter(arrayAdapter);

      listView.setChoiceMode(choiceMode);

      Log.e(name, “onCreate”);// 顯示當前狀態,onCreate與onDestroy對應

      }

      @Override

      public void onDestroy() {

      super.onDestroy();

      Log.e(name, “onDestroy”);// 顯示當前狀態,onCreate與onDestroy對應

      }

      @Override

      public void onStart() {

      super.onStart();

      Log.e(name, “onStart”);// 顯示當前狀態,onStart與onStop對應

      }

      @Override

      public void onStop() {

      super.onStop();

      Log.e(name, “onStop”);// 顯示當前狀態,onStart與onStop對應

      }

      @Override

      public void onRestart() {

      super.onRestart();

      Log.e(name, “onRestart”);

      }

      @Override

      public void onResume() {

      super.onResume();

      Log.e(name, “onResume”);// 顯示當前狀態,onPause與onResume對應

      }

      @Override

      public void onPause() {

      super.onResume();

      Log.e(name, “onPause”);// 顯示當前狀態,onPause與onResume對應

      }

      }

      

    (審核編輯: 智匯小新)

    聲明:除特別說明之外,新聞內容及圖片均來自網絡及各大主流媒體。版權歸原作者所有。如認為內容侵權,請聯系我們刪除。

    国产一区二区精品在线_午夜精品视频_亚洲国产高清高潮精品美女_久久久91_午夜精品视频_久久久久亚洲一区二区三区
    <cite id="gqusq"><tbody id="gqusq"></tbody></cite>
    <strike id="gqusq"><tbody id="gqusq"></tbody></strike>
    <abbr id="gqusq"><rt id="gqusq"></rt></abbr>
  • <strike id="gqusq"><tbody id="gqusq"></tbody></strike>
    <ul id="gqusq"></ul>
    <center id="gqusq"><noscript id="gqusq"></noscript></center>
  • 亚洲每日更新| 97中文在线| 亚洲视频日本| 久久综合给合久久狠狠色| 亚洲免费在线精品一区| 欧美日韩在线一二三| 亚洲精品中字| 欧美精品在线一区| 精品国产一区二区三区四区精华| 一区二区三区欧美成人| 在线成人国产| 欧美一区二区三区在线免费观看| 久久久久久久久久码影片| 91亚洲精品丁香在线观看| 香蕉久久a毛片| 亚洲激情专区| 国产日韩欧美| 国产一区二区三区成人欧美日韩在线观看| 欧美成人综合一区| 欧美日韩p片| 精品二区视频| 中文欧美日韩| 久久精品在线| 国产v亚洲v天堂无码| 国模精品娜娜一二三区| 精品国产中文字幕| 免费国产在线精品一区二区三区| 精品在线视频一区二区| 欧美大香线蕉线伊人久久| 欧美人与物videos另类| 日韩高清国产精品| 亚洲欧美日韩国产yyy| 亚洲一区二三| 一区在线播放| 久久综合一区| 好吊色欧美一区二区三区四区| 精品高清视频| 亚洲欧美日韩不卡一区二区三区| 亚洲mv在线看| 亚洲精品视频一区二区三区 | 在线观看视频日韩| 日韩一级精品| 97超碰最新| 欧美一二三四五区| 亚洲欧美综合| 亚洲欧美日产图| 精品在线观看一区二区| 97碰碰视频| 精品视频导航| 黄色日韩精品| 成人av免费在线看| 日本在线播放一区| 激情视频一区二区三区| 久色成人在线| 亚洲一区二区三区涩| 国产精品区一区| 免费精品视频一区二区三区| 欧美三级乱码| 成人性色av| 国产精品第十页| 国产精品久久久久久久免费大片| 日本视频一区二区不卡| 999在线观看精品免费不卡网站| 老司机久久99久久精品播放免费| 蜜桃传媒视频麻豆第一区免费观看| 伊人久久青草| 国产精品免费在线播放| 欧美日本亚洲韩国国产| 99精品国产高清一区二区| 伊人久久大香线蕉av一区| 亚洲一区三区在线观看| 亚洲激情一区二区三区| 久久一区亚洲| 国产一区视频观看| 久久99精品久久久久久水蜜桃 | 69174成人网| 欧美一区1区三区3区公司| 久久精品中文字幕一区二区三区| 亚洲午夜高清视频| 91青青草免费观看| 亚洲国产一区二区三区a毛片| 国产一区二区三区四区五区在线| 激情综合电影网| 亚洲国产高清国产精品| 国产精品区一区二区三含羞草| 欧美日本亚洲韩国国产| 欧美日韩三区四区| 久久综合伊人77777麻豆| 好吊日精品视频| 日韩欧美在线观看强乱免费| 久久一区二区三区超碰国产精品| 欧美日本在线| 亚洲一区三区视频在线观看| 精品久久久久久中文字幕动漫| 一本色道久久综合亚洲精品高清| 中文字幕久久综合| 热re99久久精品国产99热| 成人欧美一区二区三区黑人免费| 亚洲国产婷婷| 欧美日韩在线播放一区二区| 日韩中文不卡| 免费亚洲一区二区| 国产伦精品一区二区三区高清| 国产精品久久国产愉拍| 亚洲国产高清一区二区三区| 亚洲欧美久久234| 色一情一乱一伦一区二区三区丨| 成人免费视频观看视频| 久久一区激情| 久久亚洲国产精品日日av夜夜| 国产日韩精品一区观看| 一区免费在线| 亚洲人体偷拍| 日韩一级精品| 国产欧美丝祙| 一区二区日韩免费看| 一区二区三区av| 欧美性天天影院| 午夜精品久久久久99热蜜桃导演 | 国产精品国产亚洲精品看不卡15| 乱人伦精品视频在线观看| 亚欧成人精品| 91久久国产自产拍夜夜嗨| 久久精品123| 成人免费视频视频在| 精品蜜桃传媒| 日本高清一区| 欧美精品国产一区| 激情视频一区| 一本久道综合久久精品| 蜜桃视频一区| 精品欧美国产| 亚州欧美一区三区三区在线| 中文字幕一区二区三区精彩视频| 女人香蕉久久**毛片精品| 国产一区二区三区四区老人| 亚洲开发第一视频在线播放| 午夜一级在线看亚洲| 成人综合色站| 色就是色欧美| 伊人久久成人| 91免费版黄色| 神马影院一区二区| 国产在线精品二区| 久久深夜福利| 欧洲精品久久| 亚洲欧洲日韩综合二区| 老司机午夜精品视频在线观看| 久久久久九九九| 欧美日韩在线播放一区二区| 久久大香伊蕉在人线观看热2| 精品国产乱码久久久久久郑州公司| 亚洲v国产v| 亚洲一区日韩| 日韩aⅴ视频一区二区三区| 国产精品黄色| 国产精品一国产精品最新章节| 五码日韩精品一区二区三区视频| 国产精品国产三级国产专区53| 另类亚洲自拍| 夜夜爽99久久国产综合精品女不卡 | 日韩电影大全在线观看| 亚洲看片免费| 蜜桃av久久久亚洲精品| 狠狠色狠狠色综合日日tαg| 999日本视频| 欧美一区二区三区另类| 久久这里只有| 欧美日韩1080p| 国产免费一区| 亚洲国产网站| 日韩少妇中文字幕| 美女诱惑一区| 欧美精品首页| 蜜桃视频日韩| 香蕉视频成人在线观看| 亚洲精品第一区二区三区| 久久资源av| 国产精品va| 日本一区二区视频| 91传媒在线免费观看| 欧美午夜免费| 日本电影一区二区三区| 美女诱惑一区| 亚洲高清资源综合久久精品| 久久久久综合一区二区三区| 亚洲欧美日韩精品久久久| 亚洲精品高清国产一线久久| 国产精品免费在线 | 久久av最新网址| 一区二区三区我不卡| 亚洲免费久久| 精品乱码一区二区三区| 久久天天狠狠| 亚洲一区二区三区高清不卡| 欧美精品国产| 一区二区三区欧美在线| 日韩久久在线| 免费在线观看91| 精品国产_亚洲人成在线|