Instead of delaying the setContentView() call, can you inflate that layout and set its visibility to View.GONE temporarily until the actual content arrives?
j On Tue, Nov 3, 2009 at 8:52 PM, Lee Laborczfalvi <[email protected]> wrote: > I've got a tab host activity started from a home screen shortcut. > When my application starts it downloads information from a server > using an AsyncTask. In the onPostExecute method of the AsyncTask I > call setContentView to display the TabHost. > > When I start the homescreen shortcut by tapping on the shortcut using > my finger everything works as expected, I download the information > from the server and display the TabHost with the information in the > tabs. > > However starting the application by navigating to the shortcut with > the mouse wheel and then clicking on the shortcut with the mouse wheel > leads to a trap in the framework code as soon as my application > starts. The stack trace is below: > > 11-04 15:45:40.113: ERROR/AndroidRuntime(3360): Uncaught handler: > thread main exiting due to uncaught exception > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): java.lang.NullPointerException > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.widget.TabHost.onTouchModeChanged(TabHost.java:179) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:591) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.view.ViewRoot.performTraversals(ViewRoot.java:715) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.view.ViewRoot.handleMessage(ViewRoot.java:1613) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.os.Handler.dispatchMessage(Handler.java:99) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.os.Looper.loop(Looper.java:123) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > android.app.ActivityThread.main(ActivityThread.java:4203) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > java.lang.reflect.Method.invokeNative(Native Method) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > java.lang.reflect.Method.invoke(Method.java:521) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) > 11-04 15:45:40.213: ERROR/AndroidRuntime(3360): at > dalvik.system.NativeStart.main(Native Method) > > Looking at the code for the TabHost class I see the following code at > the point where the trap occurs > > 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 > TRAP ON THIS LINE ----> if (!mCurrentView.hasFocus() || > mCurrentView.isFocused()) { > > mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); > } > } > } > > This looks like a simple fix since mCurrentView is null at the time > that this method is called - can this issue be addressed? Does anyone > know of any workarounds? > > Thanks > Lee > > -- > 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 > -- Jeff Sharkey [email protected] -- 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

