Here is the part of original source code of TabHost.java which causes
a NullPointerException:
public void onTouchModeChanged(boolean isInTouchMode) {
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())
{ <-- this is line 178
mTabWidget.getChildAt(mCurrentTab).requestFocus();
}
}
}
I made several tests to find out the problems, nEx.Software is right,
i got this exception when i use the trackball. In my OnCreate method
of TabActivity, i've some background thread to retrieve the data
before displaying the TabActivity's content view. This thread takes 4
or 5 seconds, and onTouchModeChanged is called immediately, that's why
the mCurrentView is null. So what i did to resolve this problem is
disable the focus on the button which will start my TabActivity by
using setFocusable(false), so the button won't receive the onClick
event from the trackball. This is not an elegant solution, because the
onClick event only be called by finger touch, that means the
application won't work in non-touch screen device.
On 26 juin, 17:06, And-Rider <[email protected]> wrote:
> I am also having the same problem ....
>
> Can anyone help us telling the possible scenarios in which this bug
> might occur.
>
> On Jun 25, 10:17 pm, "nEx.Software" <[email protected]> wrote:
>
> > I get no errors when I use TrackBall click to select a tab in
> > TabActivity. Tested on my apps targeting each 1.1 SDK and 1.5 SDK.
> > Now, I am not using separate activities for my tab contents, so that
> > may make a difference.
>
> > On Jun 25, 2:21 am, Explore Android <[email protected]> wrote:
>
> > > I am also facing the same issue, not sure this is framework issue or
> > > application issue.
> > > Any experts have a say on this issue?
> > > (I am working with Android 1.5 SDK)
>
> > > On Jun 17, 2:26 pm, roland <[email protected]> wrote:
>
> > > > I just found a strange issue in my application which contains a
> > > > ListView. When one item is clicked, a TabActivity will be launched, i
> > > > got a NullPointerException when i press the item by using trackball.
> > > > But it's fine when i press the item by using finger.
>
> > > > This is the logcat message:
> > > > D/AndroidRuntime(32224): Shutting down VM
> > > > W/dalvikvm(32224): threadid=3: thread exiting with uncaught exception
> > > > (group=0x4000fe70)
> > > > E/AndroidRuntime(32224): Uncaught handler: thread main exiting due to
> > > > uncaught exception
> > > > E/AndroidRuntime(32224): java.lang.NullPointerException
> > > > E/AndroidRuntime(32224): at
> > > > android.widget.TabHost.onTouchModeChanged
> > > > (TabHost.java:178)
> > > > E/AndroidRuntime(32224): at
> > > > android.view.ViewTreeObserver.dispatchOnTouchModeChanged
> > > > (ViewTreeObserver.java:591)
> > > > E/AndroidRuntime(32224): at
> > > > android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1736)
> > > > E/AndroidRuntime(32224): at
> > > > android.view.ViewRoot.performTraversals
> > > > (ViewRoot.java:667)
> > > > E/AndroidRuntime(32224): at android.view.ViewRoot.handleMessage
> > > > (ViewRoot.java:1482)
> > > > E/AndroidRuntime(32224): at android.os.Handler.dispatchMessage
> > > > (Handler.java:99)
> > > > E/AndroidRuntime(32224): at
> > > > android.os.Looper.loop(Looper.java:123)
> > > > E/AndroidRuntime(32224): at android.app.ActivityThread.main
> > > > (ActivityThread.java:3948)
> > > > E/AndroidRuntime(32224): at java.lang.reflect.Method.invokeNative
> > > > (Native Method)
> > > > E/AndroidRuntime(32224): at java.lang.reflect.Method.invoke
> > > > (Method.java:521)
> > > > E/AndroidRuntime(32224): at com.android.internal.os.ZygoteInit
> > > > $MethodAndArgsCaller.run(ZygoteInit.java:782)
> > > > E/AndroidRuntime(32224): at
> > > > com.android.internal.os.ZygoteInit.main
> > > > (ZygoteInit.java:540)
> > > > E/AndroidRuntime(32224): at dalvik.system.NativeStart.main(Native
> > > > Method)
>
> > > > Has anyone met this kind of issue? Thanks for sharing your experience.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---