Here's the code:
public class MenuTabActivity extends TabActivity implements OnTabChangeListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_layout);
TabHost tb = getTabHost();
TabHost.TabSpec spec = null;
Intent intent = null;
// My Profile tab
intent = new Intent(this, MyProfileActivityGroup.class);
View myProfileView = LayoutInflater.from(this).inflate(R.layout.button_profil, null);
spec = tb.newTabSpec("0").setIndicator(myProfileView).setContent(intent);
tb.addTab(spec);
// Driving tab
intent = new Intent(this, DrivingActivityGroup.class);
View drivingView = LayoutInflater.from(this).inflate(R.layout.button_conduite, null);
spec = tb.newTabSpec("1").setIndicator(drivingView).setContent(intent);
tb.addTab(spec);
// Score Tab
intent = new Intent(this, ScoreActivityGroup.class);
View scoreView = LayoutInflater.from(this).inflate(R.layout.button_score, null);
spec = tb.newTabSpec("2").setIndicator(scoreView).setContent(intent);
tb.addTab(spec);
// Advices Tab
intent = new Intent(this, AdvicesActivity.class);
View advicesView = LayoutInflater.from(this).inflate(R.layout.button_conseils, null);
spec = tb.newTabSpec("3").setIndicator(advicesView).setContent(intent);
tb.addTab(spec);
tb.setOnTabChangedListener(this);
Main.tabBar = tb;
tb.setCurrentTab(0);
}
@Override
public void onTabChanged(String tabId) {
if (tabId.equals("2")){
//refresh third tab
((ScoreActivityGroup)(getLocalActivityManager().getActivity(tabId))).getScoreActivity().updateView();
}
if (tabId.equals("1")){ //driving activity
if (Utils.tabImage == null) {
//create the static image of the tabbar here
Bitmap tabImage = Bitmap.createBitmap(getTabHost().getTabWidget().getWidth(), getTabHost().getTabWidget().getHeight(), Bitmap.Config.RGB_565);
getTabHost().getTabWidget().draw(new Canvas(tabImage));
Utils.tabImage = tabImage;
}
//load second "tab" Activity
((DrivingActivityGroup)(getLocalActivityManager().getActivity("1"))).startDrivingActivity();
}
if (!tabId.equals("2")){
if (getLocalActivityManager().getActivity("2") != null){
if (((ScoreActivityGroup)getLocalActivityManager().getActivity("2")).getCurrentActivity() instanceof ScoreDetailsActivity){
//dismiss Conseil Dialog if it exists
((ScoreDetailsActivity)(((ScoreActivityGroup)getLocalActivityManager().getActivity("2")).getCurrentActivity())).dismissConseilDialog();
}
}
}
}
/**
* This method starts an activity with a given animation (ex: bottom-top)
* Used for info activities
*
* This action is placed here because the animations are ignored if done
* from child activities of the MenuTabActivity.
*
* @param clazz
* @param enterAnim
* @param exitAnim
* @param intentExtra
*/
public void startActivityWithOverridePendingTransition(Class<?> clazz, int enterAnim, int exitAnim, Integer intentExtra){
final Intent intent = new Intent(this, clazz);
if ( intentExtra != null ){
intent.putExtra("com.renault.Intent", intentExtra);
}
startActivity(intent);
overridePendingTransition(enterAnim, exitAnim);
}
public void onDestroy(){
super.onDestroy();
if (Main.monitoringHasStarted) {
开发者_开发知识库 Main.DriveBusinessService.stopMonitoring();
ScoringModelPojo.saveToBundle(getApplicationContext());
}
Main.monitoringHasStarted = false;
SettingsModel.saveToBundle(getApplicationContext());
}
} `
Here's the tabwidget:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight = "1"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background = "@color/grayFond"
android:layout_weight = "0"/>
</LinearLayout>
</TabHost>
Did any of you come across the issue mentioned in the title?
I found out what was wrong. It must be a bug in there. In the manifest file I had no status bar and full screen. When introducing the status bar back into the screen, (NO FULLSCREEN) it worked as it should. Maybe this helps someone.
PS. This should be filed as a bug with ANDROID. (tested in 2.1)
精彩评论