diff options
author | Romain Guy <romainguy@android.com> | 2009-08-18 17:38:14 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-08-18 17:38:14 -0700 |
commit | 7237c56faea76d43b304562828a443ca766c3c78 (patch) | |
tree | d38e3b76f8e7113520100fbf23ee9183b252f587 /core/java/android/widget/TabHost.java | |
parent | 6c8dd9841f9958ae64cd2b8540bb5de70247487c (diff) | |
download | frameworks_base-7237c56faea76d43b304562828a443ca766c3c78.zip frameworks_base-7237c56faea76d43b304562828a443ca766c3c78.tar.gz frameworks_base-7237c56faea76d43b304562828a443ca766c3c78.tar.bz2 |
Fix possible NPE on touch mode change in TabHost.
Diffstat (limited to 'core/java/android/widget/TabHost.java')
-rw-r--r-- | core/java/android/widget/TabHost.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java index 103d44d..1bee9db 100644 --- a/core/java/android/widget/TabHost.java +++ b/core/java/android/widget/TabHost.java @@ -68,7 +68,7 @@ public class TabHost extends FrameLayout implements ViewTreeObserver.OnTouchMode initTabHost(); } - private final void initTabHost() { + private void initTabHost() { setFocusableInTouchMode(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); @@ -134,7 +134,8 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); mTabContent = (FrameLayout) findViewById(com.android.internal.R.id.tabcontent); if (mTabContent == null) { throw new RuntimeException( - "Your TabHost must have a FrameLayout whose id attribute is 'android.R.id.tabcontent'"); + "Your TabHost must have a FrameLayout whose id attribute is " + + "'android.R.id.tabcontent'"); } } @@ -176,7 +177,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1"); if (!isInTouchMode) { // leaving touch mode.. if nothing has focus, let's give it to // the indicator of the current tab - if (!mCurrentView.hasFocus() || mCurrentView.isFocused()) { + if (mCurrentView != null && (!mCurrentView.hasFocus() || mCurrentView.isFocused())) { mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); } } |