• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android TabWidget

roolandb

Lurker
I'm creating android application and I encountered a problem with tabs. They are working as they should, but in one of my tabs there are a button that leads to another class and it opens a whole new window and the tabs disappear, but I want it to open with the tabs staying at the top of my screen. Any suggestions?
This is my tab code:
Code:
package team.revo2;

import team.revo2.WorkoutsActivity;
import team.revo2.ProgressActivity;
import team.revo2.TimerActivity;
import team.revo2.CalendarActivity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;


public class MyMenu extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
//		Resources res = getResources();
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec;		
		Intent intent;
		
		intent = new Intent().setClass(this, WorkoutsActivity.class);
		spec = tabHost
				.newTabSpec("workouts")
				.setIndicator("Workouts" , null)
				.setContent(intent);
		tabHost.addTab(spec);
		
		intent = new Intent().setClass(this, ProgressActivity.class);
		spec = tabHost
				.newTabSpec("progress")
				.setIndicator("Progress" , null)
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, TimerActivity.class);
		spec = tabHost
				.newTabSpec("timer")
				.setIndicator("Timer" , null)
				.setContent(intent);
		tabHost.addTab(spec);
		
		intent = new Intent().setClass(this, CalendarActivity.class);
		spec = tabHost
				.newTabSpec("calendar")
				.setIndicator("Calendar" , null)
				.setContent(intent);
		tabHost.addTab(spec);
		tabHost.setCurrentTab(2);
	}
}
 
Back
Top Bottom