From 7ec212f1185e4dd43d765b22d65485d141037ae6 Mon Sep 17 00:00:00 2001 From: Cheng Ke Date: Wed, 14 Mar 2012 10:58:35 +0800 Subject: [PATCH] Remove tab only if tab exists. Prevent crash in ActionBarTabs(ApiDemos). Change-Id: I1972fc761e8ebf245afb828fe7595bc764eaae56 --- .../src/com/example/android/apis/app/ActionBarTabs.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java index 11c1bc279..df6752c98 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java @@ -52,7 +52,9 @@ public class ActionBarTabs extends Activity { public void onRemoveTab(View v) { final ActionBar bar = getActionBar(); - bar.removeTabAt(bar.getTabCount() - 1); + if (bar.getTabCount() > 0) { + bar.removeTabAt(bar.getTabCount() - 1); + } } public void onToggleTabs(View v) {