当前位置: 首页>>代码示例>>Java>>正文


Java TabSpec类代码示例

本文整理汇总了Java中android.widget.TabHost.TabSpec的典型用法代码示例。如果您正苦于以下问题:Java TabSpec类的具体用法?Java TabSpec怎么用?Java TabSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TabSpec类属于android.widget.TabHost包,在下文中一共展示了TabSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_base_clear_cache);
		
		//1.����ѡ�1
		TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator("��������");
//		ImageView imageView = new ImageView(this); 
//		imageView.setBackgroundResource(R.drawable.ic_launcher);
//		View view = View.inflate(this, R.layout.test, null);
		
//		TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator(view);
		
		//2.����ѡ�2
		TabSpec tab2 = getTabHost().newTabSpec("sd_cache_clear").setIndicator("sd������");
		
		//3.��֪����ѡ���������
		tab1.setContent(new Intent(this,CacheClearActivity.class));
		tab2.setContent(new Intent(this,SDCacheClearActivity.class));
		
		//4.��������ѡ�ά��host(ѡ�����)��ȥ
		getTabHost().addTab(tab1);
		getTabHost().addTab(tab2);
	}
 
开发者ID:cckevincyh,项目名称:mobilesafe,代码行数:25,代码来源:BaseCacheClearActivity.java

示例2: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTabHost = (TabHost) findViewById(R.id.edit_item_tab_host);
    mTabHost.setup(getLocalActivityManager());

    TabSpec tabCall = mTabHost.newTabSpec("TAB_Call");
    tabCall.setIndicator("电话");
    tabCall.setContent(new Intent(this, AnswerCallActivity.class));
    mTabHost.addTab(tabCall);

    TabSpec tabMessage = mTabHost.newTabSpec("TAB_Message");
    tabMessage.setIndicator("短信");
    tabMessage.setContent(new Intent(this, AnswerMessageActivity.class));
    mTabHost.addTab(tabMessage);

    mTabHost.setCurrentTab(0);
}
 
开发者ID:jp1017,项目名称:AutoAnswerCalls,代码行数:20,代码来源:MainActivity.java

示例3: init

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
public void init(FragmentTabHost fragmentTabHost, Activity activity) {
	this.activity = activity;
       // 得到fragment的个数
       int count = classArray.length;

       for (int i = 0; i < count; i++) {
           // 给每个Tab按钮设置图标、文字和内容
           TabSpec tabSpec = fragmentTabHost.newTabSpec(labelArray[i]).setIndicator(
                   getTabItemView(i, activity));
           // 将Tab按钮添加进Tab选项卡中
           fragmentTabHost.addTab(tabSpec, classArray[i], null);

           // 设置Tab按钮的背景
           //mTabHost.getTabWidget().getChildAt(i)
           // .setBackgroundResource(R.drawable.tt_tab_bk);
       }
	this.selectTab(0);
	fragmentTabHost.setOnTabChangedListener(this);
}
 
开发者ID:xuhuisheng,项目名称:lemon-android,代码行数:20,代码来源:FragmentHelper.java

示例4: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	 setContentView(R.layout.fragment_main);
	

	tabHost =(FragmentTabHost) findViewById(R.id.fth_main);
	tabHost.setup(getApplication(), getSupportFragmentManager(), R.id.fl_main);
	
	for (int i = 0; i < 5; i++) {
		TabSpec tab = tabHost.newTabSpec(i+"");
		
		View view = LayoutInflater.from(this).inflate(R.layout.menu, null);

	  	ImageView ivType = (ImageView) view.findViewById(R.id.iv_iconType);
	  	TextView tvName = (TextView) view.findViewById(R.id.tv_name);
	  	ivType.setImageResource(ResUtils.menuIds[i]);
	  	tvName.setText(ResUtils.menuStrs[i]);
		tab.setIndicator(view);
		
		Bundle b = new Bundle();
		b.putInt("position", i);
		tabHost.addTab(tab, MenuFragment.class, b);
		}
	
}
 
开发者ID:BarryLiu,项目名称:AndroidDemos,代码行数:27,代码来源:FragmentMain.java

示例5: initTabs

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
private void initTabs() {
    MainTab[] tabs = MainTab.values();
    final int size = tabs.length;
    for (int i = 0; i < size; i++) {
        MainTab mainTab = tabs[i];
        TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName()));

        View indicator = inflateView(R.layout.v2_tab_indicator);
        ImageView icon = (ImageView) indicator.findViewById(R.id.tab_icon);
        icon.setImageResource(mainTab.getResIcon());
        TextView title = (TextView) indicator.findViewById(R.id.tab_titile);
        title.setText(getString(mainTab.getResName()));
        tab.setIndicator(indicator);
        tab.setContent(new TabContentFactory() {

            @Override
            public View createTabContent(String tag) {
                return new View(MainActivity.this);
            }
        });

        mTabHost.addTab(tab, mainTab.getClz(), null);

    }
}
 
开发者ID:leerduo,项目名称:OschinaMainFrameWorkWithToolBar,代码行数:26,代码来源:MainActivity.java

示例6: createOnePOSTab

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
/** Creates tab with part of entry related to one language and one part of speech, 
 * runs POS activity. 
 **/ 
public void createOnePOSTab(TPage _tpage, TLang _tlang, TLangPOS _lang_pos) {
   
    Bundle b = new Bundle();
    b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id
    b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id
    b.putInt("lang_pos_id", _lang_pos.getID()); // pass parameter: TLangPOS by lang_pos_id
    
    Intent i = new Intent(this, WCPOSActivity.class);
    
    i.putExtras(b);
    //System.out.println("Source activity: page_id = " + _tpage.getID() 
    //                    + "; lang_id = " + _tlang.getID()
    //                    + "; lang_pos_id = " + _lang_pos.getID());
    
    TabSpec _tabspec = tab_host_pos.newTabSpec( "" + _lang_pos.getID() ); // some unique text
    _tabspec.setIndicator( getShortPOSText(_lang_pos) );
    _tabspec.setContent(i);
    tab_host_pos.addTab(_tabspec);
}
 
开发者ID:componavt,项目名称:wikokit,代码行数:23,代码来源:WCLanguageActivity.java

示例7: createOneLanguageTab

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
/** Creates tab with part of entry related to one language, 
 * runs language activity. 
 **/ 
public void createOneLanguageTab(TPage _tpage, TLang _tlang) {  //TLangPOS _lang_pos) {
   
    Bundle b = new Bundle();
    b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id
    b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id
    
    Intent i = new Intent(this, WCLanguageActivity.class);
    //Intent i = new Intent().setClass(this, WCLanguageActivity.class);  
    
    i.putExtras(b);
    //System.out.println("Source activity: page_id = " + _tpage.getID() + "; lang_id = " + _tlang.getID());
    
    TabSpec _tabspec = tab_host_languages.newTabSpec( "" + _tlang.getID() ); // some unique text

    LanguageType _lang = _tlang.getLanguage();
    _tabspec.setIndicator(_lang.getCode());
    _tabspec.setContent(i);
    
    tab_host_languages.addTab(_tabspec);
}
 
开发者ID:componavt,项目名称:wikokit,代码行数:24,代码来源:WCActivity.java

示例8: initView

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
private void initView() {
	mLayoutInflater = LayoutInflater.from(this);

	mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
	mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

	int count = mFragmentArray.length;
	for (int i = 0; i < count; i++) {
		TabSpec spec = mTabHost.newTabSpec(getString(mTextArray[i]));
		spec.setIndicator(getTabItemView(i));

		mTabHost.addTab(spec, mFragmentArray[i], null);

		// mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_item_backgound_selector);
		mTabHost.getTabWidget().setDividerDrawable(null);
	}
}
 
开发者ID:alwaystrong,项目名称:BottomTabBar,代码行数:18,代码来源:MainActivity.java

示例9: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.file_tab);
	
	Resources res = getResources(); // Resource object to get Drawables
       TabHost tabHost = getTabHost();  // The activity TabHost
       TabSpec spec;
       Intent intent;  // Reusable Intent for each tab
   
     //��һ��TAB
       intent = new Intent(this,FileActivity.class);//�½�һ��Intent����Tab1��ʾ������
       spec = tabHost.newTabSpec("�����ļ�")//�½�һ�� Tab
       .setIndicator("�����ļ�", res.getDrawable(android.R.drawable.ic_menu_manage))//���������Լ�ͼ��
       .setContent(intent);//������ʾ��intent������IJ���Ҳ������R.id.xxx
       tabHost.addTab(spec);//��ӽ�tabHost
   
       //�ڶ���TAB
       intent = new Intent(this,VDiskFileActivity.class);//�ڶ���Intent����Tab2��ʾ������
       spec = tabHost.newTabSpec("΢��VDisk")//�½�һ�� Tab
       .setIndicator("΢��VDisk", res.getDrawable(android.R.drawable.ic_dialog_map))//���������Լ�ͼ��
       .setContent(intent);//������ʾ��intent������IJ���Ҳ������R.id.xxx
       tabHost.addTab(spec);//��ӽ�tabHost
       
       tabHost.setCurrentTab(0);
}
 
开发者ID:tongcpp,项目名称:VDiskExplorer,代码行数:27,代码来源:FileTabActivity.java

示例10: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) 
{

	super.onCreate(savedInstanceState);

	setContentView(R.layout.activity_main_tabhost);

	TabHost tabHost = getTabHost();
	
	TabSpec tabSpec1 = tabHost.newTabSpec("Home");
	TabSpec tabSpec2 = tabHost.newTabSpec("Second");

	tabSpec1.setIndicator("Home");
	tabSpec2.setIndicator("Second");
	Intent photosIntent = new Intent(this, GridViewActivity.class);
	Intent secondactivIntent = new Intent(this, SecondActivity.class);
	tabSpec1.setContent(photosIntent);
	tabSpec2.setContent(secondactivIntent);

	tabHost.addTab(tabSpec1);
	tabHost.addTab(tabSpec2);


}
 
开发者ID:joaogithub,项目名称:Testes,代码行数:27,代码来源:TabsActivity.java

示例11: initTabs

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
/**
 * initializes the pages in the tabbed dialog
 */
protected void initTabs() {
	// Setup the tabbed dialog on the layout and add the content of each tab
	TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
	tabHost.setup();
	TabSpec localTabSpec = tabHost.newTabSpec(localTabString());
	localTabSpec.setContent(R.id.localGameTab);
	localTabSpec.setIndicator(localTabString());
	TabSpec remoteTabSpec = tabHost.newTabSpec(remoteTabString());
	remoteTabSpec.setContent(R.id.remoteGameTab);
	remoteTabSpec.setIndicator(remoteTabString());
	tabHost.addTab(localTabSpec);
	tabHost.addTab(remoteTabSpec);
	
	// make sure the current tab is the right one
	tabHost.setCurrentTab(config.isLocal() ? 0 : 1);

}
 
开发者ID:MaxRobinson,项目名称:Phase10,代码行数:21,代码来源:GameMainActivity.java

示例12: initTabSpec

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@SuppressLint("InflateParams")
private void initTabSpec() {

	int count = getTabItemCount();

	for (int i = 0; i < count; i++) {
		// set text view
		View tabItem = mLayoutflater.inflate(R.layout.api_tab_item, null);

		ImageView tvTabItem = (ImageView) tabItem
				.findViewById(R.id.tab_item_iv);
		setTabItemTextView(tvTabItem, i);
		// set id
		String tabItemId = getTabItemId(i);
		// set tab spec
		TabSpec tabSpec = mTabHost.newTabSpec(tabItemId);
		tabSpec.setIndicator(tabItem);
		tabSpec.setContent(getTabItemIntent(i));

		mTabHost.addTab(tabSpec);
	}

}
 
开发者ID:andongniao,项目名称:AiStore,代码行数:24,代码来源:TabHostActivity.java

示例13: initTabs

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
private void initTabs()
{
    mTabHost = (TabHost)mView.findViewById(android.R.id.tabhost);
    mTabHost.setup();
    
    final TabSpec spec1 = mTabHost.newTabSpec(TAB_TAG_INFO);
    spec1.setContent(R.id.color_info_view_tab_info);
    spec1.setIndicator(getString(R.string.color_info_tab_info));
    
    final TabSpec spec2 = mTabHost.newTabSpec(TAB_TAG_SIMILAR);
    spec2.setContent(R.id.color_info_view_tab_similar);
    spec2.setIndicator(getString(R.string.color_info_tab_similar));
    
    mTabHost.addTab(spec1);
    mTabHost.addTab(spec2);
}
 
开发者ID:TianziHou,项目名称:tzPalette,代码行数:17,代码来源:ColorInfoDialogFragment.java

示例14: onCreate

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab);
    TabHost host = (TabHost)findViewById(android.R.id.tabhost);
    TabSpec spec = host.newTabSpec("tab1");
    spec.setContent(R.id.tab1);
    spec.setIndicator("Button1");
    
    host.addTab(spec);
    spec = host.newTabSpec("tab2");
    spec.setContent(R.id.tab2);
    spec.setIndicator("Next Button");
    host.addTab(spec);
    spec = host.newTabSpec("tab3");
    spec.setContent(R.id.tab3);
    spec.setIndicator("Just some text");
    host.addTab(spec);
    
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:22,代码来源:TabTest.java

示例15: createTabSpec

import android.widget.TabHost.TabSpec; //导入依赖的package包/类
@SuppressLint("InflateParams")
private TabSpec createTabSpec(TabHost tabHost, String tag,
       Resources res, int labelId, int iconId, Class<?> cls) {
	TabSpec spec = tabHost.newTabSpec(tag);
	String label = res.getString(labelId);
	Drawable icon = res.getDrawable(iconId);

	LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.tab, null);
	((ImageView) linearLayout.findViewById(R.id.tab_icon)).setImageDrawable(icon);
	((TextView) linearLayout.findViewById(R.id.tab_label)).setText(label);
	spec.setIndicator(linearLayout);
	spec.setContent(new Intent().setClass(this, cls));
			
	return spec;

}
 
开发者ID:mingzhou,项目名称:LogisticsPlatform,代码行数:17,代码来源:MainActivity.java


注:本文中的android.widget.TabHost.TabSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。