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


Java TabHost.setCurrentTab方法代码示例

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


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

示例1: onClick

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    if (AppData.getInstance().hasUserSetServerData()) {
        switch (view.getId()) {
            case btnEmergency:
                sendCommandToRestService("normal");
                break;
            case btnRequestGreenLong:
                sendCommandToRestService("extended");
                break;
        }
        TabHost host = (TabHost) getActivity().findViewById(android.R.id.tabhost);
        host.setCurrentTab(1); //1 = PedestrianTab
    } else {
        final TextView textView = (TextView) this.view.findViewById(R.id.txtView_ErrorMsg);
        textView.setText("set/apply REST server ip:port");
    }
}
 
开发者ID:shreaker,项目名称:V2I-Traffic-Light-Demonstrator,代码行数:19,代码来源:PedestrianTab.java

示例2: onCreate

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

  TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
  tabHost.setup();
  
  tabHost.addTab(tabHost.newTabSpec("t1").setIndicator(getString(R.string.folder_new)).setContent(this));
  tabHost.addTab(tabHost.newTabSpec("t2").setIndicator(getString(R.string.folder_existing)).setContent(this));
  tabHost.setCurrentTab(0);
  tabHost.setOnTabChangedListener(this);

  onTabChanged(null);

  mIconPicker = new IconPicker(this, true);
  mIconSelect = (ImageView) findViewById(R.id.folder_icon);
  mIconSelect.setOnClickListener(this);
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:21,代码来源:FolderPick.java

示例3: onCreate

import android.widget.TabHost; //导入方法依赖的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

示例4: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.medical_records, container, false);
    mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
    mTabHost = (TabHost) rootView.findViewById(android.R.id.tabhost);
    mHorizontalScroll = (HorizontalScrollView) rootView.findViewById(R.id.horizontal_scroll_view);
    mTabHost.setCurrentTab(1);

    avatar = (ImageView) rootView.findViewById(R.id.user_avatar);
    userCode = (TextView) rootView.findViewById(R.id.user_code);
    fullName = (TextView) rootView.findViewById(R.id.full_name);
    birthDate = (TextView) rootView.findViewById(R.id.birth_date);
    specialty = (TextView) rootView.findViewById(R.id.specialty2);

    return rootView;
}
 
开发者ID:maysamrasoli,项目名称:Doctor,代码行数:17,代码来源:UserProfile.java

示例5: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_my_files, container, false);

    myFileList = (ListView) v.findViewById(R.id.myFileList);
    myFileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    myFileList.setOnItemClickListener(this);

    allEntities = FileSelectHelper.getFileEntities(FileSelectorActivity.getServerResponse());

    // Init tab host categories {My files}
    tabHostMyFile = (TabHost) v.findViewById(R.id.tabHostMyFiles);
    tabHostMyFile.setup();

    initTabHost(tabHostMyFile, getMyFilesCategories(allEntities));
    tabHostMyFile.setOnTabChangedListener(new MyFilesCategoriesListener());

    myFileList.setAdapter(getArrayAdapterForMyFiles(allEntities, tabHostMyFile.getCurrentTabTag()));

    FileEntity currentEntity = FileSelectorActivity.getCurrentEntity();
    tabHostMyFile.setCurrentTab(currentTab);
    FileSelectorActivity.setCurrentEntity(currentEntity);

    return v;
}
 
开发者ID:SequencingDOTcom,项目名称:RTP-API-Gradle-Maven-Android-File-Selector-Java,代码行数:27,代码来源:MyFileActivity.java

示例6: onCreate

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

	mContext = this;

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

	LayoutInflater i = LayoutInflater.from(this);
	i.inflate(R.layout.tab_login, tabhost.getTabContentView());
	i.inflate(R.layout.tab_register, tabhost.getTabContentView());// ��̬����XML��������ҪActivity

	tabhost.addTab(tabhost.newTabSpec("tab1").setIndicator("��¼").setContent(R.id.tab_login));
	tabhost.addTab(tabhost.newTabSpec("tab2").setIndicator("ע��").setContent(R.id.tab_register));
	// ������ʵ��ǩ
	tabhost.setCurrentTab(0);

	findViewById(R.id.bt_cancle).setOnClickListener(this);
	findViewById(R.id.bt_confirm).setOnClickListener(this);
	findViewById(R.id.bt_rcancle).setOnClickListener(this);
	findViewById(R.id.bt_rconfirm).setOnClickListener(this);
	findViewById(R.id.btn_show_id).setOnClickListener(this);

	et_id = (EditText) findViewById(R.id.et_id);
	et_password = (EditText) findViewById(R.id.et_password);
	et_rid = (EditText) findViewById(R.id.et_rid);
	et_rpassword = (EditText) findViewById(R.id.et_rpassword);
	et_rpassword2 = (EditText) findViewById(R.id.et_rpassword2);
	et_remail = (EditText) findViewById(R.id.et_remail);
	et_rphonenum = (EditText) findViewById(R.id.et_rphonenum);
	et_rnum = (EditText) findViewById(R.id.et_rnum);

	lv_showid = (ListView) findViewById(R.id.lv_showid);

	MylistAdapter mylistAdapter = new MylistAdapter();
	lv_showid.setAdapter(mylistAdapter);
	lv_showid.setOnItemClickListener(this);
}
 
开发者ID:REIGE,项目名称:AndroidTest,代码行数:41,代码来源:LoginActivity.java

示例7: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_tab_host, container, false);

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

    TabHost.TabSpec tab1 = tabhost.newTabSpec("tab1");
    tab1.setIndicator("タブ1");
    tab1.setContent(R.id.tab1);
    tabhost.addTab(tab1);

    TabHost.TabSpec tab2 = tabhost.newTabSpec("tab2");
    tab2.setIndicator("タブ2");
    tab2.setContent(R.id.tab2);
    tabhost.addTab(tab2);

    TabHost.TabSpec tab3 = tabhost.newTabSpec("tab3");
    tab3.setIndicator("タブ3");
    tab3.setContent(R.id.tab3);
    tabhost.addTab(tab3);

    tabhost.setCurrentTab(0);

    return rootView;
}
 
开发者ID:yokmama,项目名称:honki_android2,代码行数:28,代码来源:TabHostFragment.java

示例8: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TabHost tabHost = getTabHost();
    addTab(tabHost, "Pictures", ImageListActivity.class);
    addTab(tabHost, "Videos", VideoListActivity.class);

    // start on video tab if requested
    if (this.getIntent().getBooleanExtra("video", false)) {
	    tabHost.setCurrentTab(1);
    }
}
 
开发者ID:dozingcat,项目名称:WireGoggles,代码行数:13,代码来源:MediaTabActivity.java

示例9: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_sample_files, container, false);

    sampleFileList = (ListView) v.findViewById(R.id.sampleFileList);
    sampleFileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    sampleFileList.setOnItemClickListener(this);

    allEntities = FileSelectHelper.getFileEntities(FileSelectorActivity.getServerResponse());

    // Init tab host categories { Sample files}
    tabHostSampleFile = (TabHost) v.findViewById(R.id.tabHostSampleFiles);
    tabHostSampleFile.setup();

    initTabHost(tabHostSampleFile, getSampleFilesSubCategories());
    tabHostSampleFile.setOnTabChangedListener(new SampleFilesCategoriesListener());

    ArrayAdapter<SpannableString> listAdapter = null;
    if(tabHostSampleFile.getCurrentTabTag().equals(FileSelectHelper.ATTR_SAMPLE_ALL)) {
        listAdapter = getArrayAdapterForSampleFiles(allEntities, null);
    } else {
        listAdapter = getArrayAdapterForSampleFiles(allEntities, tabHostSampleFile.getCurrentTabTag());
    }
    sampleFileList.setAdapter(listAdapter);

    FileEntity currentEntity = FileSelectorActivity.getCurrentEntity();
    tabHostSampleFile.setCurrentTab(currentTab);
    FileSelectorActivity.setCurrentEntity(currentEntity);

    return v;
}
 
开发者ID:SequencingDOTcom,项目名称:RTP-API-Gradle-Maven-Android-File-Selector-Java,代码行数:33,代码来源:SampleFileActivity.java

示例10: createTabs

import android.widget.TabHost; //导入方法依赖的package包/类
private void createTabs(final TabHost tabHost, int grid, int scroll) {
    tabHost.setup();
    // Set divider only works if called before adding the tabs
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        tabHost.getTabWidget().setShowDividers(TabWidget.SHOW_DIVIDER_MIDDLE);
        tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider_dark);
    } else {
        tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
    }

    for (int index = TextAdapter.INFO_PREV + 1; index < TextAdapter.INFO_NEXT; index++) {
        switch (index) {
            case TextAdapter.INFO_ARRIVALS:
            TabSpec spec = tabHost.newTabSpec("arrivals");
            // Set the content of the tab
            spec.setIndicator(createSingleTab(R.string.info_arrivals));
            // Set the content of the framelayout when this tab is selected
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_FLEETS:
            spec = tabHost.newTabSpec("fleets");
            spec.setIndicator(createSingleTab(R.string.info_fleets));
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_STATS:
            spec = tabHost.newTabSpec("stats");
            spec.setIndicator(createSingleTab(R.string.info_stats));
            spec.setContent(scroll);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_THREATS:
            spec = tabHost.newTabSpec("threats");
            spec.setIndicator(createSingleTab(R.string.info_threats));
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;
        }
    }
    tabHost.setCurrentTab(mStateInfoTab);

    InfoView tabContent = (InfoView) tabHost.findViewById(android.R.id.tabcontent);
    tabContent.setEventListener(new IEventListenerInfoView() {
        @Override
        public void onSingleTap() {
            setInfoTab(TextAdapter.INFO_NEXT);
        }
        @Override
        public void onLongPress() {
            // InfoTab changed to stop animations on long press
            if (mExpandedInfoTab) {
                toggleExpandedLayout();
            }
            if (mStateInfoTab != TextAdapter.INFO_FLEETS && mStateInfoTab != TextAdapter.INFO_STATS) {
                setInfoTab(TextAdapter.INFO_STATS);
            }
        }
        @Override
        public void onFling(){
            toggleExpandedLayout();
        }
    });

}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:69,代码来源:GameActivity.java

示例11: onCreate

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

    Resources ressources = getResources();
    TabHost tabHost = getTabHost();

    // video tab
    Intent intentvideo = new Intent().setClass(this, Video_Activity.class);
    TabHost.TabSpec tabSpec1 = tabHost
            .newTabSpec("Videos")
            .setIndicator("Videos")
            .setContent(intentvideo);

    //music tab
    Intent intentmusic = new Intent().setClass(this,Music_Activity.class);
    TabHost.TabSpec tabSpec2 = tabHost
            .newTabSpec("Music")
            .setIndicator("Music")
            .setContent(intentmusic);

    // images tab
    Intent intentimages = new Intent().setClass(this, Image_Activity.class);
    TabHost.TabSpec tabSpec3 = tabHost
            .newTabSpec("Images")
            .setIndicator("Images")
            .setContent(intentimages);

    //pdf tab
    Intent intentpdf = new Intent().setClass(this,pdf_activity.class);
    TabHost.TabSpec tabSpec4= tabHost
            .newTabSpec("PDF")
            .setIndicator("PDF")
            .setContent(intentpdf);

    // add all tabs
    tabHost.addTab(tabSpec1);
    tabHost.addTab(tabSpec2);
    tabHost.addTab(tabSpec3);
    tabHost.addTab(tabSpec4);

    //set Windows tab as default (zero based)
    tabHost.setCurrentTab(0);
}
 
开发者ID:Mohnish226,项目名称:SendIt,代码行数:45,代码来源:FileBrowser.java

示例12: onCreate

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

	Resources res = getResources(); // Resource object to get Drawables
	TabHost tabHost = getTabHost();
	TabHost.TabSpec spec; // Reusable TabSpec for each tab
	Intent intent; // Reusable Intent for each tab
	// Initialize a TabSpec for each tab and add it to the TabHost

	intent = new Intent().setClass(this, OtherActivity.class).putExtra(
			DEMOKEY, Reflection.CONVERGING_LENS);
	spec = tabHost.newTabSpec(Reflection.CONVERGING_LENS.toString())
			.setIndicator("", res.getDrawable(R.drawable.concavelensic))
			.setContent(intent);
	tabHost.addTab(spec);

	intent = new Intent().setClass(this, OtherActivity.class).putExtra(
			DEMOKEY, Reflection.DIVERGING_LENS);
	spec = tabHost.newTabSpec(Reflection.DIVERGING_LENS.toString())
			.setIndicator("", res.getDrawable(R.drawable.convexlensic))
			.setContent(intent);
	tabHost.addTab(spec);

	intent = new Intent().setClass(this, OtherActivity.class).putExtra(
			DEMOKEY, Reflection.CONVERGING_MIRROR);
	spec = tabHost.newTabSpec(Reflection.CONVERGING_MIRROR.toString())
			.setIndicator("", res.getDrawable(R.drawable.concavemirroric))
			.setContent(intent);
	tabHost.addTab(spec);

	intent = new Intent().setClass(this, OtherActivity.class).putExtra(
			DEMOKEY, Reflection.DIVERGING_MIRROR);
	spec = tabHost.newTabSpec(Reflection.DIVERGING_MIRROR.toString())
			.setIndicator("", res.getDrawable(R.drawable.convexmirroric))
			.setContent(intent);
	tabHost.addTab(spec);

	intent = new Intent().setClass(this, PrismActivity.class);
	spec = tabHost.newTabSpec("prism").setIndicator("",
			res.getDrawable(R.drawable.prism_tab)).setContent(intent);
	tabHost.addTab(spec);
	
	// These two are not finished.
	/*
	intent = new Intent().setClass(this, MicroscopeActivity.class);
	spec = tabHost.newTabSpec("microscope").setIndicator("",
			res.getDrawable(R.drawable.microscope)).setContent(intent);
	tabHost.addTab(spec);
	
	intent = new Intent().setClass(this, TelescopeActivity.class);
	spec = tabHost.newTabSpec("telescope").setIndicator("", 
			res.getDrawable(R.drawable.telescope)).setContent(intent);
	tabHost.addTab(spec);
	*/		

	intent = new Intent().setClass(this, ViewActivity.class).putExtra(
			"content", R.raw.documentation);
	spec = tabHost.newTabSpec("doc1").setIndicator("",
			res.getDrawable(android.R.drawable.ic_dialog_info)).setContent(
			intent);
	tabHost.addTab(spec);

	tabHost.setCurrentTab(0);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:66,代码来源:An_StartActivity.java

示例13: switchToStatusCarTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void switchToStatusCarTab() {
    TabHost host = (TabHost) getActivity().findViewById(android.R.id.tabhost);
    host.setCurrentTab(0); //0 = StatusCarTab
}
 
开发者ID:shreaker,项目名称:V2I-Traffic-Light-Demonstrator,代码行数:5,代码来源:SettingsTab.java

示例14: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
	prefEditor = prefs.edit();
	getUserPreferences();
	
	powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
	wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "RSSI_SCREEN_ON");
	locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
	telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
	wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
	sensorManager  = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
	SensorsDevice = sensorManager.getSensorList(Sensor.TYPE_ALL);
	
	if (isFirstTime){
		showDialog(WELCOME_DIALOG);
		prefEditor.putBoolean("firsttime", false);
		prefEditor.commit();
	}

	prefs.registerOnSharedPreferenceChangeListener(this);
	
	// Setting Tabs Views
	Resources res = getResources();
	TabHost tabHost = getTabHost();
	tabHost.addTab(tabHost.newTabSpec("Cellular").setIndicator("Network"
	,res.getDrawable(R.drawable.ic_tab_cellular)).setContent(R.id.cellulartabLayout));
	tabHost.addTab(tabHost.newTabSpec("Sensors").setIndicator("Sensors"
			,res.getDrawable(R.drawable.ic_tab_sensors)).setContent(R.id.sensortabLayout));
	tabHost.addTab(tabHost.newTabSpec("GPS").setIndicator("location"
	,res.getDrawable(R.drawable.ic_tab_gps)).setContent(R.id.gpstabLayout));
	tabHost.addTab(tabHost.newTabSpec("Wifi").setIndicator("Wifi"
	,res.getDrawable(R.drawable.ic_tab_wifi)).setContent(R.id.wifitabLayout));
	tabHost.addTab(tabHost.newTabSpec("Log").setIndicator("Log"
	,res.getDrawable(R.drawable.ic_tab_log)).setContent(R.id.logtabLayout));
	tabHost.setCurrentTab(0);

	// initialize the toggle button
	button = (ToggleButton)findViewById(R.id.button_toggle);
	if (isLogging)
		button.setChecked(true);
	button.setOnCheckedChangeListener(this);
}
 
开发者ID:baharxy,项目名称:mobility-logger,代码行数:47,代码来源:MainActivity.java

示例15: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if (BuildConfig.DEBUG) Log.d(TAG, "onCreate()");

	mApp = (BoincManagerApplication)getApplication();

	// Create handler for screen orientation
	mScreenOrientation = new ScreenOrientationHandler(this);

	// Obtain screen wake-lock
	PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
	mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getPackageName());

	doBindService();

	requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
	setContentView(R.layout.main_view);

	TabHost tabHost = getTabHost();
	Resources res = getResources();

	// Tab 1 - Projects
	tabHost.addTab(tabHost.newTabSpec("tab_projects")
			.setIndicator(getString(R.string.projects), res.getDrawable(R.drawable.ic_tab_projects))
			.setContent(new Intent(this, ProjectsActivity.class)));

	// Tab 2 - Tasks
	tabHost.addTab(tabHost.newTabSpec("tab_tasks")
			.setIndicator(getString(R.string.tasks), res.getDrawable(R.drawable.ic_tab_tasks))
			.setContent(new Intent(this, TasksActivity.class)));

	// Tab 3 - Transfers
	tabHost.addTab(tabHost.newTabSpec("tab_transfers")
			.setIndicator(getString(R.string.transfers), res.getDrawable(R.drawable.ic_tab_transfers))
			.setContent(new Intent(this, TransfersActivity.class)));

	// Tab 4 - Messages
	tabHost.addTab(tabHost.newTabSpec("tab_messages")
			.setIndicator(getString(R.string.messages), res.getDrawable(R.drawable.ic_tab_messages))
			.setContent(new Intent(this, MessagesActivity.class)));

	// Set all tabs one by one, to start all activities now
	// It is better to receive early updates of data
	tabHost.setCurrentTabByTag("tab_messages");
	tabHost.setCurrentTabByTag("tab_tasks");
	tabHost.setCurrentTabByTag("tab_transfers");
	tabHost.setCurrentTabByTag("tab_projects");
	// Set saved tab (the last selected on previous run) as current
	SharedPreferences globalPrefs = PreferenceManager.getDefaultSharedPreferences(this);
	int lastActiveTab = globalPrefs.getInt(PreferenceName.LAST_ACTIVE_TAB, 1);
	tabHost.setCurrentTab(lastActiveTab);

	// Restore state on configuration change (if applicable)
	final SavedState savedState = (SavedState)getLastNonConfigurationInstance();
	if (savedState != null) {
		// Yes, we have the saved state, this is activity re-creation after configuration change
		savedState.restoreState(this);
	}
	else {
		// Just normal start
		ClientId clientId = getIntent().getParcelableExtra(ClientId.TAG);
		if (clientId == null) {
			String autoConnectHost = globalPrefs.getString(PreferenceName.AUTO_CONNECT_HOST, null);
			if ((autoConnectHost != null) && globalPrefs.getBoolean(PreferenceName.AUTO_CONNECT, false)) {
				// We should auto-connect to recently connected host
				HostListDbAdapter dbHelper = new HostListDbAdapter(this);
				dbHelper.open();
				mSelectedClient = dbHelper.fetchHost(autoConnectHost);
				if (BuildConfig.DEBUG) Log.d(TAG, "Will auto-connect to " + mSelectedClient.getAddress() + ":" + mSelectedClient.getPort());
				dbHelper.close();
			}
		}
	}
}
 
开发者ID:palo-m,项目名称:androboinc,代码行数:76,代码来源:BoincManagerActivity.java


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