當前位置: 首頁>>代碼示例>>Java>>正文


Java OnTabChangeListener類代碼示例

本文整理匯總了Java中android.widget.TabHost.OnTabChangeListener的典型用法代碼示例。如果您正苦於以下問題:Java OnTabChangeListener類的具體用法?Java OnTabChangeListener怎麽用?Java OnTabChangeListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnTabChangeListener類屬於android.widget.TabHost包,在下文中一共展示了OnTabChangeListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initView

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
private void initView() {
    mAddItem = (LinearLayout) findViewById(R.id.main_add_item);
    mTabHost = (FragmentTabHost) findViewById(R.id.main_tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.main_container);
    mTabHost.setBackgroundColor(getResources().getColor(R.color.bg_tabhost));
    mTabHost.getTabWidget().setDividerDrawable(null);
    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (tabId.equals(BlackListFragmet.NAME)) {
                mActionBar.setTitle("黑名單", LocalActionBar.MIDDLE_TITLE);
        //        mAddItem.setVisibility(View.VISIBLE);
            } else {
                mActionBar.setTitle("添加", LocalActionBar.MIDDLE_TITLE);
        //        mAddItem.setVisibility(View.GONE);
            }
        }
    });
    addTabItem(BlackListFragmet.NAME, "黑名單", BlackListFragmet.TAB_ICON, BlackListFragmet.class);
    addTabItem(AddDataFragment.NAME, "添加", AddDataFragment.TAB_ICON, AddDataFragment.class);
}
 
開發者ID:facetome,項目名稱:Interceptor,代碼行數:22,代碼來源:MainActivity.java

示例2: initTabHost

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
private void initTabHost() {

        final TabHost mTabHost = (TabHost) findViewById(android.R.id.tabhost);

        mTabHost.addTab(createTabSpec(mTabHost, R.string.tab_password1, R.id.tab_password,
                "password1"));
        mTabHost.addTab(createTabSpec(mTabHost, R.string.tab_password2, R.id.tab_password,
                "password2"));        
        mTabHost.addTab(createTabSpec(mTabHost, R.string.tab_pin, R.id.tab_pin, "pin"));
        mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
			
			@Override
			public void onTabChanged(String tabId) {
				if ("password1".equals(tabId)) {
					hash = profiles[0];
					generateIfValid();
				} else if ("password2".equals(tabId)) {
					hash = profiles[1];
					generateIfValid();
				}
			}
		});
    }
 
開發者ID:pdudits,項目名稱:supergenpass-android,代碼行數:24,代碼來源:Super_Gen_Pass.java

示例3: FileGalleryPreviewDialog

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
public FileGalleryPreviewDialog(Context context) {
	super(context);
	
	View dialogView = getLayoutInflater().inflate(R.layout.label_dialog, null);
	setView(dialogView);
	
	setButton(DialogInterface.BUTTON_POSITIVE, getContext().getResources().getString(R.string.confirm_dialog_button),
			new OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// do nothing
				}
			});
	
	tabHost = (TabHost) dialogView.findViewById(R.id.label_tabhost);
	tabHost.setup();
	
	tabHost.setOnTabChangedListener(new OnTabChangeListener() {
		
		@Override
		public void onTabChanged(String tabId) {
			// Hide/show video preview so it's not visible in background on tab change
			if ("video_preview".equals(tabId)) {
				videoView.setVisibility(View.VISIBLE);
				videoView.start();
			} else {
				if (videoView != null) {
					videoView.setVisibility(View.GONE);
				}
			}
		}
	});
}
 
開發者ID:FAIMS,項目名稱:faims-android,代碼行數:35,代碼來源:FileGalleryPreviewDialog.java

示例4: LabelDialog

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@SuppressLint("InflateParams")
public LabelDialog(Context context) {
	super(context);
	
	tabs = new ArrayList<String>();
	tabSpecs = new ArrayList<TabHost.TabSpec>();
	
	setButton(DialogInterface.BUTTON_NEGATIVE, getContext().getResources().getString(R.string.cancel_dialog_button),
			new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			// User cancelled the dialog
		}
	});

	View labelDialogView = getLayoutInflater().inflate(R.layout.label_dialog, null);
	setView(labelDialogView);
	
	tabHost = (TabHost) labelDialogView.findViewById(R.id.label_tabhost);
	tabHost.setup();
	// Hide soft keyboard on tab change
	tabHost.setOnTabChangedListener(new OnTabChangeListener() {
		
		@Override
		public void onTabChanged(String tabId) {
			handleTabChange(tabId);
		}
	});
}
 
開發者ID:FAIMS,項目名稱:faims-android,代碼行數:31,代碼來源:LabelDialog.java

示例5: init

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
private void init() {
	tabhost = this.getTabHost();

	first = tabhost.newTabSpec("first");
	second = tabhost.newTabSpec("second");		
	
	// ָ��ѡ������֣�ͼ��
	first.setIndicator(createContent("���", R.drawable.first_tab));
	second.setIndicator(createContent("����", R.drawable.two_tab));
	
	// ����ʾ��ҳ��
	first.setContent(new Intent(this, InspectionActivity.class));
	second.setContent(new Intent(this, SettingActivity.class));
	
	// ��ѡ��ӽ�TabHost
	tabhost.addTab(first);
	tabhost.addTab(second);
	//�趨��ǰTab
	tabhost.setCurrentTab(0);
	// ����tabHost�л�ʱ��̬����ͼ��
	tabhost.setOnTabChangedListener(new OnTabChangeListener() {

		@Override
		public void onTabChanged(String tabId) {
			tabChanged(tabId);
		}

	});
	
}
 
開發者ID:donghaoli,項目名稱:EquitmentInspection,代碼行數:31,代碼來源:MainActivity.java

示例6: initialiseTabHost

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
/**
 * Initializes the tabhost and updates the viewpager when tab changed.
 */
private void initialiseTabHost() {
	_tabhost = (TabHost) findViewById(android.R.id.tabhost);
	_tabhost.setup();
	_tabhost.setOnTabChangedListener(new OnTabChangeListener() {

		@SuppressLint("NewApi")
		@Override
		public void onTabChanged(String tabId) {
			int pos = _tabhost.getCurrentTab();
			if(android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.HONEYCOMB)
			{
				switch(pos)
				{
				case 0:
					EasyTracker.getInstance(ctx).send(MapBuilder.createEvent("ui_action", "tab_change", "authority_info_tab", null).build());
					getActionBar().setTitle("Authority Info");
					invalidateOptionsMenu();
					previousBackCount = backCount;
					backCount = 0;
					break;
				case 1:
					EasyTracker.getInstance(ctx).send(MapBuilder.createEvent("ui_action", "tab_change", "user_info_tab", null).build());
					getActionBar().setTitle("User Info");
					invalidateOptionsMenu();
					backCount = previousBackCount;
				}
			}
			_pager.setCurrentItem(pos);
		}
	});
}
 
開發者ID:liarosge,項目名稱:apps4thess,代碼行數:35,代碼來源:AlertsActivity.java

示例7: initTabs

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
private void initTabs()
{
    mTabHost = (TabHost)mView.findViewById(android.R.id.tabhost);
    mTabHost.setup();
    
    final TabSpec spec1 = mTabHost.newTabSpec(TAB_TAG_RGB);
    spec1.setContent(R.id.color_edit_view_tab_rgb);
    spec1.setIndicator(getString(R.string.color_edit_tab_rgb));
    
    final TabSpec spec2 = mTabHost.newTabSpec(TAB_TAG_RGB);
    spec2.setContent(R.id.color_edit_view_tab_hsv);
    spec2.setIndicator(getString(R.string.color_edit_tab_hsv));
    
    mTabHost.addTab(spec1);
    mTabHost.addTab(spec2);
    
    mTabHost.setOnTabChangedListener(new OnTabChangeListener(){
        @Override
        public void onTabChanged(String tabId)
        {
            updateColor();
            
            if (mCallback != null)
                mCallback.onTabChanged(ColorEditView.this, 
                                       mTabHost.getCurrentTab(), 
                                       mTabHost.getCurrentTabTag());
        }
    });
}
 
開發者ID:TianziHou,項目名稱:tzPalette,代碼行數:30,代碼來源:ColorEditView.java

示例8: onCreate

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
protected void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_tab);
		tabHost=this.getTabHost();

		
        //添加選項卡
		tabHost.addTab(tabHost.newTabSpec("TAB_GPS").setIndicator("TAB_GPS")
        			.setContent(new Intent(this, ui.activity.gps.GpsObtainActivity.class)));
		tabHost.addTab(tabHost.newTabSpec("TAB_MAP").setIndicator("TAB_MAP")
        		.setContent(new Intent(this,ui.activity.GoogleMap.GMapActivity.class)));
		tabHost.addTab(tabHost.newTabSpec("TAB_WEATHER").setIndicator("TAB_WEATHER")
        		.setContent(new Intent(this,ui.activity.weather.WeatherActivity.class))); 
//		tabHost.addTab(tabHost.newTabSpec("TAB_COMMUNITY").setIndicator("TAB_COMMUNITY")
//        		.setContent(new Intent(this,ui.activity.community.CommunityActivity.class))); 
//		tabHost.addTab(tabHost.newTabSpec("TAB_COMMUNITY").setIndicator("TAB_COMMUNITY")
//        		.setContent(new Intent(this,ui.activity.community.Communitymain.class))); 
		
        radioderGroup = (RadioGroup) findViewById(R.id.main_radio);
		radioderGroup.setOnCheckedChangeListener(this);

		this.tabHost.setOnTabChangedListener(new OnTabChangeListener() {

			@Override
			public void onTabChanged(String tabId) {
				// TODO Auto-generated method stub
			}
		});
	}
 
開發者ID:Tifosi-M,項目名稱:Hi-Top,代碼行數:31,代碼來源:MainActivity.java

示例9: setOnTabChangedListener

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
public void setOnTabChangedListener(OnTabChangeListener l) {
    this.mOnTabChangeListener = l;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:FragmentTabHost.java

示例10: setOnTabChangedListener

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
public void setOnTabChangedListener(OnTabChangeListener onTabChangeListener) {
    this.f78e = onTabChangeListener;
}
 
開發者ID:Qwaz,項目名稱:solved-hacking-problem,代碼行數:4,代碼來源:FragmentTabHost.java

示例11: onCreate

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	if (Controller.getInstance().getPreferences()
			.getBoolean(Constants.PREFERENCES_SHOW_FULL_SCREEN, false)) {
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}

	if (Controller
			.getInstance()
			.getPreferences()
			.getBoolean(Constants.PREFERENCES_GENERAL_HIDE_TITLE_BARS, true)) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
	}

	setContentView(R.layout.bookmarks_history_activity);

	setTitle(R.string.BookmarksListActivity_Title);

	Resources res = getResources();
	TabHost tabHost = getTabHost();
	TabHost.TabSpec spec;
	Intent intent;

	// Bookmarks
	intent = new Intent().setClass(this, BookmarksListActivity.class);

	spec = tabHost
			.newTabSpec("bookmarks")
			.setIndicator(res.getString(R.string.Main_MenuShowBookmarks),
					res.getDrawable(R.drawable.ic_tab_bookmarks))
			.setContent(intent);
	tabHost.addTab(spec);

	// History
	intent = new Intent().setClass(this, HistoryListActivity.class);

	spec = tabHost
			.newTabSpec("history")
			.setIndicator(res.getString(R.string.Main_MenuShowHistory),
					res.getDrawable(R.drawable.ic_tab_history))
			.setContent(intent);
	tabHost.addTab(spec);

	if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
			Constants.PREFERENCE_USE_WEAVE, false)) {
		// Weave bookmarks
		intent = new Intent().setClass(this,
				WeaveBookmarksListActivity.class);

		spec = tabHost
				.newTabSpec("weave")
				.setIndicator(
						res.getString(R.string.WeaveBookmarksListActivity_Title),
						res.getDrawable(R.drawable.ic_tab_weave))
				.setContent(intent);
		tabHost.addTab(spec);
	}

	tabHost.setCurrentTab(0);

	tabHost.setOnTabChangedListener(new OnTabChangeListener() {
		@Override
		public void onTabChanged(String tabId) {
			if (tabId.equals("bookmarks")) {
				setTitle(R.string.BookmarksListActivity_Title);
			} else if (tabId.equals("history")) {
				setTitle(R.string.HistoryListActivity_Title);
			} else if (tabId.equals("weave")) {
				setTitle(R.string.WeaveBookmarksListActivity_Title);
			} else {
				setTitle(R.string.ApplicationName);
			}
		}
	});
}
 
開發者ID:tommy4711,項目名稱:gaeproxy,代碼行數:79,代碼來源:BookmarksHistoryActivity.java

示例12: init

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@AfterViews
public void init() {
       mFragmentManager = getActivity().getSupportFragmentManager();
       mTabHost.setup(getActivity(), mFragmentManager, R.id.realtabcontent);

       mTabHost.addTab(createSpec(Constants.TAB_SEATCH_HOUSE, getString(R.string.main_tab_search_house)), GeneratedClassUtils.get(SearchHouseFragment.class), null);
       mTabHost.addTab(createSpec(Constants.TAB_POST, getString(R.string.main_tab_post)), GeneratedClassUtils.get(ReleaseFragment.class), null);
       mTabHost.addTab(createSpec(Constants.TAB_MINE, getString(R.string.main_tab_mine)), GeneratedClassUtils.get(MineFragment.class), null);

       mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
           @Override
           public void onTabChanged(String tabId) {
               View searchHouseView = mTabHost.getTabWidget().getChildTabViewAt(0);
               View postView = mTabHost.getTabWidget().getChildTabViewAt(1);
               View mineView = mTabHost.getTabWidget().getChildTabViewAt(2);
               TextView searchTextView = (TextView) searchHouseView.findViewById(R.id.main_tab_item);
               TextView postTextView = (TextView) postView.findViewById(R.id.main_tab_item);
               TextView mineTextView = (TextView) mineView.findViewById(R.id.main_tab_item);
               if (tabId.equals(Constants.TAB_SEATCH_HOUSE)) {
                   searchTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_search_pre, 0, 0, 0);
                   searchTextView.setTextColor(Color.parseColor(Constants.SLECTED_TEXT_COLOR));
                   postTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_post_org, 0, 0, 0);
                   postTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
                   mineTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_agent_org, 0, 0, 0);
                   mineTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
               } else if (tabId.equals(Constants.TAB_POST)) {
                   searchTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_search_org, 0, 0, 0);
                   searchTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
                   postTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_post_pre, 0, 0, 0);
                   postTextView.setTextColor(Color.parseColor(Constants.SLECTED_TEXT_COLOR));
                   mineTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_agent_org, 0, 0, 0);
                   mineTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
               } else if (tabId.equals(Constants.TAB_MINE)) {
                   searchTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_search_org, 0, 0, 0);
                   searchTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
                   postTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_post_org, 0, 0, 0);
                   postTextView.setTextColor(Color.parseColor(Constants.UNSLECTED_TEXT_COLOR));
                   mineTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tabbar_ic_agent_pre, 0, 0, 0);
                   mineTextView.setTextColor(Color.parseColor(Constants.SLECTED_TEXT_COLOR));
               }
           }
       });

       mTabHost.getTabWidget().setDividerDrawable(null);

       mTabHost.setCurrentTab(1);
   }
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:48,代碼來源:MainFragment.java

示例13: onCreate

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
       //requestWindowFeature(Window.FEATURE_NO_TITLE);
      // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.activity_main);
	ViewUtils.inject(this);
	context = this;
	ActionBar actionBar = getActionBar();
       actionBar.setTitle("護眼精靈");
       listview = (ListView) findViewById(R.id.listviewApp);
       listview =new ListView(this);
       // tvInfo = (TextView)findViewById(R.id.tvInfo) ;
       mlistAppInfo = new ArrayList<RunningAppInfo>();
       listInfo =new ArrayList<RunningAppInfo>();
       pieView = (PieView) this.findViewById(R.id.lotteryView);
       pieView=new PieView(this,0);
       myButton=(MyButton)this.findViewById(R.id.MyBt);
      // myButton=new MyButton(this);
       textView=(TextView)this.findViewById(R.id.MyTV);
      // textView =new TextView(this);
       //initView();
       Intent intent = getIntent();
       int pid = intent.getIntExtra("EXTRA_PROCESS_ID", -1);
       //注冊廣播,監聽後台Service發送過來的廣播
       receiver = new UITimeReceiver();
       IntentFilter filter = new IntentFilter(TIME_CHANGED_ACTION);
       this.registerReceiver(receiver, filter);
       //啟動服務,時間改變後發送廣播,通知UI層修改時間
       startTimeService();
	// --------------------
	tabHost = (TabHost) findViewById(android.R.id.tabhost);
	tabHost.setup();
	tabHost.addTab(tabHost.newTabSpec("0").setIndicator(createTab("健康評估", 0)).setContent(android.R.id.tabcontent));
       tabHost.addTab(tabHost.newTabSpec("1").setIndicator(createTab("使用統計", 1)).setContent(android.R.id.tabcontent));
	tabHost.addTab(tabHost.newTabSpec("2").setIndicator(createTab("設置", 2)).setContent(android.R.id.tabcontent));
	// 點擊tabHost 來切換不同的消息
	tabHost.setOnTabChangedListener(new OnTabChangeListener() {
		@Override
		public void onTabChanged(String tabId) {
			int index = Integer.parseInt(tabId);
			setTabSelectedState(index, 3);
			tabHost.getTabContentView().setVisibility(View.GONE);// 隱藏content
		}
	});

       tabHost.setCurrentTab(0);
	initJazzyPager(TransitionEffect.Standard);



   }
 
開發者ID:ZhuFengdaaa,項目名稱:Chuangxinbei,代碼行數:53,代碼來源:MainActivity1.java

示例14: onCreate

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.main);

	FragmentTabHost tabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
	tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
	//1
	tabHost.addTab(tabHost.newTabSpec("Apple")
		   				  .setIndicator("Apple"), 
  					  AppleFragment.class, 
  					  null);
    //2
	tabHost.addTab(tabHost.newTabSpec("Google")
			   			  .setIndicator("Google"), 
				  GoogleFragment.class, 
				  null);
    //3
	tabHost.addTab(tabHost.newTabSpec("Facebook")
			   			  .setIndicator("Facebook"), 
				  FacebookFragment.class, 
			      null);
	
	tabHost.setOnTabChangedListener(new OnTabChangeListener() {
		
		@Override
		public void onTabChanged(String tabId) {
			
		}
	});
	
	back = (View) findViewById(R.id.navi_back);
       back.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			finish();
			
		}
	});
}
 
開發者ID:givemepassxd999,項目名稱:dialogdemo,代碼行數:43,代碼來源:FragmentTabActivity.java

示例15: onCreate

import android.widget.TabHost.OnTabChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {		
	super.onCreate(savedInstanceState);
	
	if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_SHOW_FULL_SCREEN, false)) {        	
       	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
       }
       
       if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_GENERAL_HIDE_TITLE_BARS, true)) {
       	requestWindowFeature(Window.FEATURE_NO_TITLE);
       }
	
	setContentView(R.layout.bookmarks_history_activity);
	
	setTitle(R.string.BookmarksListActivity_Title);
	
	Resources res = getResources();
	TabHost tabHost = getTabHost();
	TabHost.TabSpec spec;
	Intent intent;
	
	// Bookmarks
	intent = new Intent().setClass(this, BookmarksListActivity.class);
	
	spec = tabHost.newTabSpec("bookmarks").setIndicator(res.getString(R.string.Main_MenuShowBookmarks),
               res.getDrawable(R.drawable.ic_tab_bookmarks))
               .setContent(intent);
	tabHost.addTab(spec);
	
	// History
	intent = new Intent().setClass(this, HistoryListActivity.class);

	spec = tabHost.newTabSpec("history").setIndicator(res.getString(R.string.Main_MenuShowHistory),
               res.getDrawable(R.drawable.ic_tab_history))
               .setContent(intent);
	tabHost.addTab(spec);

	if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.PREFERENCE_USE_WEAVE, false)) {
		// Weave bookmarks
		intent = new Intent().setClass(this, WeaveBookmarksListActivity.class);

		spec = tabHost.newTabSpec("weave").setIndicator(res.getString(R.string.WeaveBookmarksListActivity_Title),
				res.getDrawable(R.drawable.ic_tab_weave))
				.setContent(intent);
		tabHost.addTab(spec);
	}
	
	tabHost.setCurrentTab(0);
	
	tabHost.setOnTabChangedListener(new OnTabChangeListener() {			
		@Override
		public void onTabChanged(String tabId) {
			if (tabId.equals("bookmarks")) {
				setTitle(R.string.BookmarksListActivity_Title);
			} else if (tabId.equals("history")) {
				setTitle(R.string.HistoryListActivity_Title);
			} else if (tabId.equals("weave")) {
				setTitle(R.string.WeaveBookmarksListActivity_Title);
			} else {
				setTitle(R.string.ApplicationName);
			}
		}
	});
}
 
開發者ID:mashiwoo,項目名稱:zirco-browser,代碼行數:65,代碼來源:BookmarksHistoryActivity.java


注:本文中的android.widget.TabHost.OnTabChangeListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。