Здравствуйте, я получаю текущую вкладку о повороте экрана со следующим кодом:
@Override
public Object onRetainNonConfigurationInstance()
{
return CurrentTab;
}
CurrentTab
установлено ранее (onTabChange) ...
При повороте экрана я записываю полученные данные:
if (getLastNonConfigurationInstance() != null &&
(Integer)getLastNonConfigurationInstance() >= 0 &&
(Integer)getLastNonConfigurationInstance() < 4)
{
CurrentTab = (Integer)getLastNonConfigurationInstance();
Log.d(" - OOOOK", "Stevilo je: " + CurrentTab.toString());
}
createView();
В createView у меня есть следующий код:
private void createView()
{
/** TabHost will have Tabs */
tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setOnTabChangedListener(this);
tabHost.clearAllTabs();
/** TabSpec used to create a new tab.
* By using TabSpec only we can able to setContent to the tab.
* By using TabSpec setIndicator() we can set name to tab. */
/** tid1 is firstTabSpec Id. Its used to access outside. */
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
TabSpec forthTabSpec = tabHost.newTabSpec("tid1");
/** TabSpec setIndicator() is used to set name for the tab. */
/** TabSpec setContent() is used to set content for a particular tab. */
firstTabSpec.setIndicator("Kanali", getResources().getDrawable(R.drawable.menu_channels)).setContent(new Intent(this,Channels.class));
secondTabSpec.setIndicator("Trenutno", getResources().getDrawable(R.drawable.menu_current)).setContent(new Intent(this,Currently.class));
thirdTabSpec.setIndicator("Opomnik", getResources().getDrawable(R.drawable.menu_reminder)).setContent(new Intent(this,Reminders.class));
forthTabSpec.setIndicator("O programu", getResources().getDrawable(R.drawable.menu_about)).setContent(new Intent(this,About.class));
/** Add tabSpec to the TabHost to display. */
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
tabHost.addTab(thirdTabSpec);
tabHost.addTab(forthTabSpec);
/** applying a theme to app */
tabHost.setBackgroundColor(Color.WHITE);
LinearLayout linearTabHost = (LinearLayout) tabHost.getChildAt(0);
TabWidget tw = (TabWidget) linearTabHost.getChildAt(0);
/* style and mod tabs */
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
RelativeLayout rllf = (RelativeLayout) tw.getChildAt(i);
TextView lf = (TextView) rllf.getChildAt(1);
lf.setTextSize(12);
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.BLACK);
}
tabHost.getTabWidget().getChildAt(CurrentTab).setBackgroundColor(Color.parseColor("#666666"));
tabHost.getTabWidget().setCurrentTab(CurrentTab);
}
В результате я выбрал правильную вкладку, но всегда есть содержимое первой вкладки ... (Выбранная вкладка в порядке, показанный контент не) ...
Что я могу сделать?