android TabActivity啓動與設置tabhost.setCurretnTab(4)之前序列中添加的第一個選項卡相關聯的FragmentActivity;安卓設置默認選項卡在製表活動
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_main);
try
{
DataSource.ObjContext = this.getApplicationContext();
DataSource.ObjTabBarActivity = this;
DataSource.ObjSharedPreferences = this.getSharedPreferences("com.example", Context.MODE_PRIVATE);
if(NetworkStat)
{
new LocationUpdates(this);
this.setTabs();
}
else
{
Log.d("in TabBarActivity", "Network failure");
Toast.makeText(this.getApplicationContext(), "Network failure", Toast.LENGTH_SHORT).show();
}
}
catch(Exception ex)
{
}
}
private void setTabs()
{
addTab("Clubs", R.drawable.tab_clubs, FragmentStackClubsActivity.class);
addTab("Events", R.drawable.tab_events, FragmentStackEventsActivity.class);
addTab("Rate", R.drawable.tab_rate, FragmentStackRateActivity.class);
addTab("Loyalty", R.drawable.tab_loyalty, FragmentStackLoyaltyActivity.class);
addTab("Setting", R.drawable.tab_settings, FragmentStackSettingsActivity.class);
if(DataSource.ObjSharedPreferences.getString(DataSource.LOGIN_TAG, "false").equalsIgnoreCase("false"))
{
getTabHost().setCurrentTab(4);
DataSource.disableTabBar();
}
else
{
}
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
但問題是,它最初啓動的第一個選項卡,然後切換到第5片這樣一個線程會從第一個標籤開始,而這正是我不想也就是說,如果用戶沒有登錄在我想重定向用戶登錄(設置)選項卡。 這方面的任何幫助,高度讚賞......
我不想重新排列TabBar以便最初啓動第5個選項卡。 – khurramengr 2013-05-14 11:20:27