使用phonegap在android中创建Tabbar

时间:2013-01-14 09:51:12

标签: android cordova android-actionbar tabbar

当我使用操作栏在android(类似于iphone)中使用phonegap创建标签栏时,会显示以下错误

我想使用Android版本3.2

来解决此问题的示例程序
01-12 22:51:12.404: D/dalvikvm(1150): GC_FOR_ALLOC freed 40K, 4% free 6357K/6595K, paused 166ms
01-12 22:51:12.404: I/dalvikvm-heap(1150): Grow heap (frag case) to 6.754MB for 513744-byte allocation
01-12 22:51:12.493: D/dalvikvm(1150): GC_FOR_ALLOC freed <1K, 4% free 6859K/7111K, paused 37ms
01-12 22:51:12.574: D/dalvikvm(1150): GC_CONCURRENT freed <1K, 4% free 6859K/7111K, paused 3ms+2ms
01-12 22:51:12.724: I/CordovaLog(1150): Changing log level to DEBUG(3)
01-12 22:51:12.724: I/CordovaLog(1150): Found preference for useBrowserHistory=true
01-12 22:51:12.734: D/CordovaLog(1150): Found preference for useBrowserHistory=true
01-12 22:51:12.734: I/CordovaLog(1150): Found preference for exit-on-suspend=false
01-12 22:51:12.734: D/CordovaLog(1150): Found preference for exit-on-suspend=false
01-12 22:51:12.764: D/JsMessageQueue(1150): Set native->JS mode to 2
01-12 22:51:12.854: D/DroidGap(1150): DroidGap.init()
01-12 22:51:12.854: D/AndroidRuntime(1150): Shutting down VM
01-12 22:51:12.864: W/dalvikvm(1150): threadid=1: thread exiting with uncaught exception (group=0x40014760)
01-12 22:51:12.894: E/AndroidRuntime(1150): FATAL EXCEPTION: main
01-12 22:51:12.894: E/AndroidRuntime(1150): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.actionbar_demo/com.example.actionbar_demo.MainActivity}: java.lang.NullPointerException
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.os.Looper.loop(Looper.java:132)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread.main(ActivityThread.java:4123)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at java.lang.reflect.Method.invokeNative(Native Method)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at java.lang.reflect.Method.invoke(Method.java:491)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at dalvik.system.NativeStart.main(Native Method)
01-12 22:51:12.894: E/AndroidRuntime(1150): Caused by: java.lang.NullPointerException
01-12 22:51:12.894: E/AndroidRuntime(1150):     at com.example.actionbar_demo.MainActivity.setContentView(MainActivity.java:77)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at org.apache.cordova.DroidGap.init(DroidGap.java:343)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at org.apache.cordova.DroidGap.init(DroidGap.java:313)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at org.apache.cordova.DroidGap.loadUrl(DroidGap.java:358)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at com.example.actionbar_demo.MainActivity.onCreate(MainActivity.java:32)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.Activity.performCreate(Activity.java:4397)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-12 22:51:12.894: E/AndroidRuntime(1150):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
01-12 22:51:12.894: E/AndroidRuntime(1150):     ... 11 more

提前致谢

1 个答案:

答案 0 :(得分:0)

很抱歉,我的帖子没有评论选项.. 所以...从我看到你传递null到某种方法.. 请编辑您的问题并向我们提供导致错误的代码 它会更容易回答..

注意:在第77行的MainActivity类中查看MainActivity.setContentView 它作为参数获取null ..所以检查你的代码有什么问题..