android.widget.TabHost.TabSpec Java Examples

The following examples show how to use android.widget.TabHost.TabSpec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LauncherActivity.java    From android-apps with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_launcher);
	
	TabHost tabHost = getTabHost();
	
	TabSpec tab1 = tabHost.newTabSpec("First Tab");
	TabSpec tab2 = tabHost.newTabSpec("Second Tab");
	TabSpec tab3 = tabHost.newTabSpec("Third Tab");
	
	tab1.setIndicator("Tab1",getResources().getDrawable(R.drawable.ic_launcher));
	tab1.setContent(new Intent(this, Tab1Activity.class));
	
	tab2.setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher));
	tab2.setContent(new Intent(this, Tab2Activity.class));
	
	tab3.setIndicator("Tab3",getResources().getDrawable(R.drawable.ic_launcher));
	tab3.setContent(new Intent(this, Tab3Activity.class));
	
	tabHost.addTab(tab1);
	tabHost.addTab(tab2);
	tabHost.addTab(tab3);
	
}
 
Example #2
Source File: LauncherActivity.java    From android-apps with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_launcher);
	
	TabHost tabHost = getTabHost();
	
	TabSpec tab1 = tabHost.newTabSpec("First Tab");
	TabSpec tab2 = tabHost.newTabSpec("Second Tab");
	TabSpec tab3 = tabHost.newTabSpec("Third Tab");
	
	tab1.setIndicator("Tab1",getResources().getDrawable(R.drawable.ic_launcher));
	tab1.setContent(new Intent(this, Tab1Activity.class));
	
	tab2.setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher));
	tab2.setContent(new Intent(this, Tab2Activity.class));
	
	tab3.setIndicator("Tab3",getResources().getDrawable(R.drawable.ic_launcher));
	tab3.setContent(new Intent(this, Tab3Activity.class));
	
	tabHost.addTab(tab1);
	tabHost.addTab(tab2);
	tabHost.addTab(tab3);
	
}
 
Example #3
Source File: TabTest.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/** 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);
    
}
 
Example #4
Source File: GestionAlumnos.java    From android with GNU General Public License v2.0 6 votes vote down vote up
private void cargaPestanas() {
	
	Resources res = getResources();
    
    TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
    tabHost.setup();
    
    TabSpec tbListadoAlumnos = tabHost.newTabSpec(res.getString(R.string.listado_alumnos_title));
    	tbListadoAlumnos.setContent(R.id.tab1);
    	tbListadoAlumnos.setIndicator(res.getString(R.string.listado_alumnos_title), res.getDrawable(android.R.drawable.ic_menu_slideshow));
    tabHost.addTab(tbListadoAlumnos);
    
    TabSpec tbNuevoAlumno = tabHost.newTabSpec(res.getString(R.string.nuevo_alumno_title));
 	tbNuevoAlumno.setContent(R.id.tab2);
 	tbNuevoAlumno.setIndicator(res.getString(R.string.nuevo_alumno_title), res.getDrawable(android.R.drawable.ic_menu_edit));
	tabHost.addTab(tbNuevoAlumno);
    
    tabHost.setCurrentTab(0);
    
    tabHost.setOnTabChangedListener(this);
}
 
Example #5
Source File: FragmentTabHost.java    From letv with Apache License 2.0 5 votes vote down vote up
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(this.mContext));
    String tag = tabSpec.getTag();
    TabInfo info = new TabInfo(tag, clss, args);
    if (this.mAttached) {
        info.fragment = this.mFragmentManager.findFragmentByTag(tag);
        if (!(info.fragment == null || info.fragment.isDetached())) {
            FragmentTransaction ft = this.mFragmentManager.beginTransaction();
            ft.detach(info.fragment);
            ft.commit();
        }
    }
    this.mTabs.add(info);
    addTab(tabSpec);
}
 
Example #6
Source File: ColorPickerDialog.java    From memoir with Apache License 2.0 5 votes vote down vote up
private void createTabs() {
    mTabHost.clearAllTabs();
    mTabHost.setOnTabChangedListener(null);        // or we would get NPEs in onTabChanged() when calling addTab()
    TabSpec tabSpec1 = mTabHost.newTabSpec(WHEEL_TAG)
            .setIndicator(mContext.getString(R.string.color_picker_wheel))
            .setContent(mFactory);
    TabSpec tabSpec2 = mTabHost.newTabSpec(EXACT_TAG)
            .setIndicator(mContext.getString(R.string.color_picker_exact))
            .setContent(mFactory);
    mTabHost.addTab(tabSpec1);
    mTabHost.addTab(tabSpec2);
    mTabHost.setOnTabChangedListener(this);
    String tag = mCurrentTab != null ? mCurrentTab : WHEEL_TAG;
    mTabHost.setCurrentTabByTag(tag);
}
 
Example #7
Source File: TestTabActvity.java    From GPT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test_tab_activity);
    mTabHost = (TabHost) getTabHost();
    Intent intent1 = new Intent(this, AnimationExampleActivity.class);
    TabSpec tabSpec = mTabHost.newTabSpec(AnimationExampleActivity.class.toString()).setIndicator("Tab1")
            .setContent(intent1);
    mTabHost.addTab(tabSpec);
    Intent intent2 = new Intent(this, AnimationTranslateActivity.class);
    TabSpec tabSpec2 = mTabHost.newTabSpec(AnimationTranslateActivity.class.toString()).setIndicator("Tab2")
            .setContent(intent2);
    mTabHost.addTab(tabSpec2);

}
 
Example #8
Source File: MainActivity.java    From FragmentMixViewPager with Apache License 2.0 5 votes vote down vote up
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 = LayoutInflater.from(getApplicationContext())
				.inflate(R.layout.tab_indicator, null);
		TextView title = (TextView) indicator.findViewById(R.id.tab_title);
		Drawable drawable = this.getResources().getDrawable(
				mainTab.getResIcon());
		title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null,
				null);

		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);

		mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this);
	}
}
 
Example #9
Source File: MainFrameActivity.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
/**
 * Convenient method to add a tab to the tab widget at bottom.
 * 
 * @param resId The resource id of image shown on indicator
 * @param content The class type of content
 */
private void addTab(int resId, Class<? extends Fragment> content) {
    ImageView indicator = new ImageView(this);
    indicator.setScaleType(ScaleType.CENTER_INSIDE);
    indicator.setBackgroundResource(R.drawable.tab_bg);
    indicator.setImageResource(resId);
    TabSpec spec = tabHost.newTabSpec(content.getSimpleName()).setIndicator(indicator);
    tabHost.addTab(spec, content, null);
}
 
Example #10
Source File: RMBTResultPagerFragment.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
private View createView(View v, LayoutInflater inflater, int currentPage) {
	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
	tabHost.setup();
	tabHost.setOnTabChangedListener(this);
	
	for (int i = 0; i < pagerAdapter.getCount(); i++) {
		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
		tab.setContent(android.R.id.tabcontent);
		    		
		
		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
		TextView title = (TextView) indicator.findViewById(android.R.id.title);
		title.setText(getActivity().getResources().getStringArray(R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP.get(i)]);
		
		if (MAP_INDICATOR_DYNAMIC_VISIBILITY) {
			if (i == RMBTResultPagerAdapter.RESULT_PAGE_MAP) {
				indicator.setVisibility(View.GONE);
			}
		}
		tab.setIndicator(indicator);
		
		tabHost.addTab(tab);
	}
	
	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
	
    viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);
    
    viewPager.setOnPageChangeListener(this);
    setCurrentPosition(currentPage);

    return v;
}
 
Example #11
Source File: QoSTestDetailPagerFragment.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
    super.onCreateView(inflater, container, savedInstanceState);
    
    View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
	tabHost.setup();
	tabHost.setOnTabChangedListener(this);
	
	for (int i = 0; i < pagerAdapter.getCount(); i++) {
		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
		tab.setContent(android.R.id.tabcontent);
		    		    		
		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
		TextView title = (TextView) indicator.findViewById(android.R.id.title);
		title.setText(pagerAdapter.getPageTitle(i));
		tab.setIndicator(indicator);
		tabHost.addTab(tab);
	}

    viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);
    
    viewPager.setOnPageChangeListener(this);
    setCurrentPosition(0);

	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
   	viewPager.setCurrentItem(initPageIndex);
	
    return v;
}
 
Example #12
Source File: PermissionsDialog.java    From FacebookNewsfeedSample-Android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.permissions_list);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mPermissionDetails = (TextView) findViewById(R.id.permission_detail);
    mPermissionDetails.setMovementMethod(LinkMovementMethod.getInstance());

    userPermissionsList = (ListView) findViewById(R.id.user_permissions_list);
    friendPermissionsList = (ListView) findViewById(R.id.friend_permissions_list);
    extendedPermissionsList = (ListView) findViewById(R.id.extended_permissions_list);

    userPermissionsAdapter = new PermissionsListAdapter(user_permissions);
    userPermissionsList.setAdapter(userPermissionsAdapter);

    friendPermissionsAdapter = new PermissionsListAdapter(friend_permissions);
    friendPermissionsList.setAdapter(friendPermissionsAdapter);

    extendedPermissionAdapter = new PermissionsListAdapter(extended_permissions);
    extendedPermissionsList.setAdapter(extendedPermissionAdapter);

    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    tabHost.setup();

    TabSpec spec1 = tabHost.newTabSpec("Tab 1");
    spec1.setIndicator(activity.getString(R.string.user));
    spec1.setContent(R.id.user_permissions_list);

    TabSpec spec2 = tabHost.newTabSpec("Tab 2");
    spec2.setIndicator(activity.getString(R.string.friend));
    spec2.setContent(R.id.friend_permissions_list);

    TabSpec spec3 = tabHost.newTabSpec("Tab 3");
    spec3.setIndicator(activity.getString(R.string.extended));
    spec3.setContent(R.id.extended_permissions_list);

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
    tabHost.setCurrentTab(0);
    tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = TAB_HEIGHT;
    tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = TAB_HEIGHT;
    tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = TAB_HEIGHT;

    mGetPermissions = (Button) findViewById(R.id.get_permissions_button);

    mGetPermissions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source Tag: perms_tag Call authorize to get the new
             * permissions
             */
            if (reqPermVector.isEmpty() && Utility.mFacebook.isSessionValid()) {
                Toast.makeText(activity.getBaseContext(), "No Permissions selected.",
                        Toast.LENGTH_SHORT).show();
                PermissionsDialog.this.dismiss();
            } else {
                String[] permissions = reqPermVector.toArray(new String[0]);
                Utility.mFacebook.authorize(activity, permissions, new LoginDialogListener());
            }
        }
    });
}
 
Example #13
Source File: WebRTCDemo.java    From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    populateCameraOrientations();

    setContentView(R.layout.tabhost);

    IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);

    receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().compareTo(Intent.ACTION_HEADSET_PLUG)
                    == 0) {
                int state = intent.getIntExtra("state", 0);
                Log.v(TAG, "Intent.ACTION_HEADSET_PLUG state: " + state +
                     " microphone: " + intent.getIntExtra("microphone", 0));
                if (voERunning) {
                    routeAudio(state == 0 && cbEnableSpeaker.isChecked());
                }
            }
        }
    };
    registerReceiver(receiver, receiverFilter);

    mTabHost = getTabHost();

    // Main tab
    mTabSpecVideo = mTabHost.newTabSpec("tab_video");
    mTabSpecVideo.setIndicator("Main");
    mTabSpecVideo.setContent(R.id.tab_video);
    mTabHost.addTab(mTabSpecVideo);

    // Shared config tab
    mTabHost = getTabHost();
    mTabSpecConfig = mTabHost.newTabSpec("tab_config");
    mTabSpecConfig.setIndicator("Settings");
    mTabSpecConfig.setContent(R.id.tab_config);
    mTabHost.addTab(mTabSpecConfig);

    TabSpec mTabv;
    mTabv = mTabHost.newTabSpec("tab_vconfig");
    mTabv.setIndicator("Video");
    mTabv.setContent(R.id.tab_vconfig);
    mTabHost.addTab(mTabv);
    TabSpec mTaba;
    mTaba = mTabHost.newTabSpec("tab_aconfig");
    mTaba.setIndicator("Audio");
    mTaba.setContent(R.id.tab_aconfig);
    mTabHost.addTab(mTaba);

    int childCount = mTabHost.getTabWidget().getChildCount();
    for (int i = 0; i < childCount; i++) {
        mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 50;
    }
    orientationListener =
            new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
                public void onOrientationChanged (int orientation) {
                    if (orientation != ORIENTATION_UNKNOWN) {
                        currentDeviceOrientation = orientation;
                        compensateCameraRotation();
                    }
                }
            };
    orientationListener.enable ();

    // Create a folder named webrtc in /scard for debugging
    webrtcDebugDir = Environment.getExternalStorageDirectory().toString() +
            webrtcName;
    File webrtcDir = new File(webrtcDebugDir);
    if (!webrtcDir.exists() && webrtcDir.mkdir() == false) {
        Log.v(TAG, "Failed to create " + webrtcDebugDir);
    } else if (!webrtcDir.isDirectory()) {
        Log.v(TAG, webrtcDebugDir + " exists but not a folder");
        webrtcDebugDir = null;
    }

    startMain();

    if (AUTO_CALL_RESTART_DELAY_MS > 0)
        startOrStop();
}
 
Example #14
Source File: QoSCategoryPagerFragment.java    From open-rmbt with Apache License 2.0 4 votes vote down vote up
@Override
 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
 {
     if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_QOS_RESULTS)) {
     	try {
	setQoSResult(new QoSServerResultCollection(new JSONArray(savedInstanceState.getString(BUNDLE_QOS_RESULTS))));
	setDetailType(DetailType.valueOf(savedInstanceState.getString(BUNDLE_DETAIL_TYPE)));
} catch (JSONException e) {
	//e.printStackTrace();
}
     }
     //DetailType detailType = DetailType.valueOf(args.getString(ARG_DETAIL_TYPE));
     pagerAdapter = new QoSCategoryPagerAdapter((RMBTMainActivity) getActivity(), handler, results);
     
     View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
 	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
 	tabHost.setup();
 	tabHost.setOnTabChangedListener(this);
 	
 	for (int i = 0; i < pagerAdapter.getCount(); i++) {
 		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
 		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
 		tab.setContent(android.R.id.tabcontent);
 		    		    		
 		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
 		TextView title = (TextView) indicator.findViewById(android.R.id.title);
 		title.setText(pagerAdapter.getPageTitle(i));
 		tab.setIndicator(indicator);
 		tabHost.addTab(tab);
 	}

     viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
     viewPager.setAdapter(pagerAdapter);
     
     viewPager.setOnPageChangeListener(this);
     setCurrentPosition(0);

 	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
 	

     if (initPosition != null) {
     	viewPager.setCurrentItem(initPosition);
     }
 	
     return v;
 }
 
Example #15
Source File: DisplayAlternativeNovelPagerActivity.java    From coolreader with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		UIHelper.SetTheme(this, R.layout.activity_display_novel_pager);
		UIHelper.SetActionBarDisplayHomeAsUp(this, true);
		setContentView(R.layout.activity_display_novel_pager);
	} else {
		UIHelper.SetTheme(this, R.layout.activity_display_novel_pager_fix);
		UIHelper.SetActionBarDisplayHomeAsUp(this, true);
		setContentView(R.layout.activity_display_novel_pager_fix);
	}
	tabHost = (TabHost) findViewById(android.R.id.tabhost);
	lam = new LocalActivityManager(this, false);
	lam.dispatchCreate(savedInstanceState);
	tabHost.setup(lam);
	isInverted = UIHelper.getColorPreferences(this);

	tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
		public void onTabChanged(String tabId) {
			setTabColor();
			currentActivity = lam.getActivity(tabId);
		}
	});

	/* Dynamically add Tabs */
	ArrayList<String> Choice = new ArrayList<String>();

	Iterator<Entry<String, AlternativeLanguageInfo>> it = AlternativeLanguageInfo.getAlternativeLanguageInfo().entrySet().iterator();
	while (it.hasNext()) {
		AlternativeLanguageInfo info = it.next().getValue();
		boolean isChosen = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(info.getLanguage(), true);
		if (isChosen) {
			Choice.add(info.getLanguage());
			Log.d("Language Added: ", info.getLanguage());
		}
		it.remove();
	}

	TabSpec[] allSpec = new TabSpec[Choice.size()];
	for (int i = 0; i < Choice.size(); i++) {
		allSpec[i] = tabHost.newTabSpec(Choice.get(i));
		allSpec[i].setIndicator(Choice.get(i));
		Intent firstIntent = new Intent(this, DisplayAlternativeNovelListActivity.class);
		firstIntent.putExtra("LANG", Choice.get(i));
		allSpec[i].setContent(firstIntent);

		// Adding all TabSpec to TabHost
		tabHost.addTab(allSpec[i]);

		// Cheap preload list hack.
		tabHost.setCurrentTabByTag(Choice.get(i));
	}

	// Tab color
	setTabColor();
}
 
Example #16
Source File: DisplayNovelPagerActivity.java    From coolreader with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		UIHelper.SetTheme(this, R.layout.activity_display_novel_pager);
		UIHelper.SetActionBarDisplayHomeAsUp(this, true);
		setContentView(R.layout.activity_display_novel_pager);
	} else {
		UIHelper.SetTheme(this, R.layout.activity_display_novel_pager_fix);
		UIHelper.SetActionBarDisplayHomeAsUp(this, true);
		setContentView(R.layout.activity_display_novel_pager_fix);
	}
	tabHost = (TabHost) findViewById(android.R.id.tabhost);
	lam = new LocalActivityManager(this, false);
	lam.dispatchCreate(savedInstanceState);
	tabHost.setup(lam);
	isInverted = UIHelper.getColorPreferences(this);

	// First Tab - Normal Novels
	TabSpec firstSpec = tabHost.newTabSpec(MAIN_SPEC);
	firstSpec.setIndicator(MAIN_SPEC);
	Intent firstIntent = new Intent(this, DisplayLightNovelListActivity.class);
	firstIntent.putExtra(Constants.EXTRA_ONLY_WATCHED, false);
	firstSpec.setContent(firstIntent);

	// Second Tab - Teasers
	TabSpec secondSpec = tabHost.newTabSpec(TEASER_SPEC);
	secondSpec.setIndicator(TEASER_SPEC);
	Intent secondIntent = new Intent(this, DisplayTeaserListActivity.class);
	secondSpec.setContent(secondIntent);

	// Third Tab - Original
	TabSpec thirdSpec = tabHost.newTabSpec(ORIGINAL_SPEC);
	thirdSpec.setIndicator(ORIGINAL_SPEC);
	Intent thirdIntent = new Intent(this, DisplayOriginalListActivity.class);
	thirdSpec.setContent(thirdIntent);

	// Adding all TabSpec to TabHost
	tabHost.addTab(firstSpec); // Adding First tab
	tabHost.addTab(secondSpec); // Adding Second tab
	tabHost.addTab(thirdSpec); // Adding third tab
	//setTabColor();

	tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
		public void onTabChanged(String tabId) {
			//setTabColor();
			currentActivity = lam.getActivity(tabId);
		}
	});

	// Cheap preload list hack.
	tabHost.setCurrentTabByTag(TEASER_SPEC);
	tabHost.setCurrentTabByTag(ORIGINAL_SPEC);
	tabHost.setCurrentTabByTag(MAIN_SPEC);

	Log.d(TAG, "Created");
}
 
Example #17
Source File: DrMIPSActivity.java    From drmips with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates/places the tabs in the Tabhost.
 */
private void createTabs() {
	tabHost = (TabHost)findViewById(android.R.id.tabhost);
	tabHost.setup();

	TabSpec tabCode = tabHost.newTabSpec("tabCode");
	tabCode.setIndicator(getString(R.string.code));
	tabCode.setContent(R.id.tabCode);
	tabHost.addTab(tabCode);
	txtCode = (EditText)findViewById(R.id.txtCode);
	lblFilename = (TextView)findViewById(R.id.lblFilename);
	txtCode.addTextChangedListener(new CodeEditorTextWatcher());
	
	TabSpec tabAssembledCode = tabHost.newTabSpec("tabAssembledCode");
	tabAssembledCode.setIndicator(getString(R.string.assembled));
	tabAssembledCode.setContent(R.id.tabAssembledCode);
	tabHost.addTab(tabAssembledCode);
	tblAssembledCode = (TableLayout)findViewById(R.id.tblAssembledCode);
	cmbAssembledCodeFormat = (Spinner)findViewById(R.id.cmbAssembledCodeFormat);
	cmbAssembledCodeFormat.setOnItemSelectedListener(spinnersListener);
	cmbAssembledCodeFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.ASSEMBLED_CODE_FORMAT_PREF, DrMIPS.DEFAULT_ASSEMBLED_CODE_FORMAT));
	
	TabSpec tabDatapath = tabHost.newTabSpec("tabDatapath");
	tabDatapath.setIndicator(getString(R.string.datapath));
	tabDatapath.setContent(R.id.tabDatapath);
	tabHost.addTab(tabDatapath);
	lblCPUFilename = (TextView)findViewById(R.id.lblCPUFilename);
	cmdStep = (ImageButton)findViewById(R.id.cmdStep);
	datapathScroll = (HorizontalScrollView)findViewById(R.id.datapathScroll);
	boolean performanceMode = DrMIPS.getApplication().getPreferences().getBoolean(DrMIPS.PERFORMANCE_MODE_PREF, DrMIPS.DEFAULT_PERFORMANCE_MODE);
	lblDatapathFormat = (TextView)findViewById(R.id.lblDatapathFormat);
	cmbDatapathFormat = (Spinner)findViewById(R.id.cmbDatapathFormat);
	cmbDatapathFormat.setOnItemSelectedListener(spinnersListener);
	cmbDatapathFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATAPATH_DATA_FORMAT_PREF, DrMIPS.DEFAULT_DATAPATH_DATA_FORMAT));
	lblDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	lblDatapathPerformance = (TextView)findViewById(R.id.lblDatapathPerformance);
	cmbDatapathPerformance = (Spinner)findViewById(R.id.cmbDatapathPerformance);
	cmbDatapathPerformance.setOnItemSelectedListener(spinnersListener);
	cmbDatapathPerformance.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.PERFORMANCE_TYPE_PREF, DrMIPS.DEFAULT_PERFORMANCE_TYPE));
	lblDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	tblExec = (TableLayout)findViewById(R.id.tblExec);
	tblExecRow = (TableRow)findViewById(R.id.tblExecRow);
	
	TabSpec tabRegisters = tabHost.newTabSpec("tabRegisters");
	tabRegisters.setIndicator(getString(R.string.registers));
	tabRegisters.setContent(R.id.tabRegisters);
	tabHost.addTab(tabRegisters);
	tblRegisters = (TableLayout)findViewById(R.id.tblRegisters);
	cmbRegistersFormat = (Spinner)findViewById(R.id.cmbRegistersFormat);
	cmbRegistersFormat.setOnItemSelectedListener(spinnersListener);
	cmbRegistersFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.REGISTER_FORMAT_PREF, DrMIPS.DEFAULT_REGISTER_FORMAT));
	
	TabSpec tabDataMemory = tabHost.newTabSpec("tabDataMemory");
	tabDataMemory.setIndicator(getString(R.string.data_memory));
	tabDataMemory.setContent(R.id.tabDataMemory);
	tabHost.addTab(tabDataMemory);
	tblDataMemory = (TableLayout)findViewById(R.id.tblDataMemory);
	cmbDataMemoryFormat = (Spinner)findViewById(R.id.cmbDataMemoryFormat);
	cmbDataMemoryFormat.setOnItemSelectedListener(spinnersListener);
	cmbDataMemoryFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATA_MEMORY_FORMAT_PREF, DrMIPS.DEFAULT_DATA_MEMORY_FORMAT));
}
 
Example #18
Source File: TrackDetailActivity.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
  photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY)
      : null;
  hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false)
      : false;
     
  myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
  handleIntent(getIntent());

  sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);

  trackRecordingServiceConnection = new TrackRecordingServiceConnection(
      this, bindChangedCallback);
  trackDataHub = TrackDataHub.newInstance(this);

  tabHost = (TabHost) findViewById(android.R.id.tabhost);
  tabHost.setup();

  viewPager = (ViewPager) findViewById(R.id.pager);

  tabsAdapter = new TabsAdapter(this, tabHost, viewPager);

  TabSpec mapTabSpec = tabHost.newTabSpec(MyTracksMapFragment.MAP_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_map_tab),
      getResources().getDrawable(R.drawable.ic_tab_map));
  tabsAdapter.addTab(mapTabSpec, MyTracksMapFragment.class, null);

  TabSpec chartTabSpec = tabHost.newTabSpec(ChartFragment.CHART_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_chart_tab),
      getResources().getDrawable(R.drawable.ic_tab_chart));
  tabsAdapter.addTab(chartTabSpec, ChartFragment.class, null);

  TabSpec statsTabSpec = tabHost.newTabSpec(StatsFragment.STATS_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_stats_tab),
      getResources().getDrawable(R.drawable.ic_tab_stats));
  tabsAdapter.addTab(statsTabSpec, StatsFragment.class, null);

  if (savedInstanceState != null) {
    tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY));
  }
  
  // Set the background after all three tabs are added
  ApiAdapterFactory.getApiAdapter().setTabBackground(tabHost.getTabWidget());
  
  trackController = new TrackController(
      this, trackRecordingServiceConnection, false, recordListener, stopListener);
}
 
Example #19
Source File: MainTabActivity.java    From coolreader with MIT License 2 votes vote down vote up
/**
 * 创建TabSpec
 * @param tag --> 每个tab项的标识
 * @param resLabel--> 每个tab项的文本
 * @param resIcon --> 每个tab项的图标
 * @param content --> 每个tab项的内容      
 * @return --> 返回一个TabSpec用于tabhost添加Tab
 */
public TabSpec newTabSpec(String tag,int resLabel,int resIcon,Intent content)
{
	return thMain.newTabSpec(tag).setIndicator(getString(resLabel),
			getResources().getDrawable(resIcon)).setContent(content);
}