Android Tab Layout 2.1
Hi all I have looked at the tutorial for creating tab layout on android on here: link
which didn't work so I looked on here to find that there where errors with it. So I applied these and still I'm not getting anywhere with it. The app loads on 2.1 emulator on eclipse and also on my phone but the application force closes each time which leads me to think that its a manifest problem. Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Android.fitnessap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TabLayout"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitl开发者_运维百科eBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".HomeActivity"/>
<activity android:name=".HistoryActivity"/>
<activity android:name=".SettingsActivity"/>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
I've been stuck on this for hours now. Thanks.
edit logcat:
01-19 18:37:09.316: ERROR/AndroidRuntime(126): ERROR: thread attach failed
01-19 18:37:10.945: ERROR/MediaPlayerService(31): Couldn't open fd for content://settings/system/notification_sound
01-19 18:37:10.955: ERROR/MediaPlayer(52): Unable to to create media player
01-19 18:37:15.345: ERROR/AndroidRuntime(170): ERROR: thread attach failed
01-19 18:37:17.215: ERROR/AndroidRuntime(197): Uncaught handler: thread main exiting due to uncaught exception
01-19 18:37:17.315: ERROR/AndroidRuntime(197): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Android.fitnessap/com.Android.fitnessap.TabLayout}: java.lang.ClassNotFoundException: com.Android.fitnessap.TabLayout in loader dalvik.system.PathClassLoader@43b868e0
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.os.Looper.loop(Looper.java:123)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at java.lang.reflect.Method.invokeNative(Native Method)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at java.lang.reflect.Method.invoke(Method.java:521)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at dalvik.system.NativeStart.main(Native Method)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): Caused by: java.lang.ClassNotFoundException: com.Android.fitnessap.TabLayout in loader dalvik.system.PathClassLoader@43b868e0
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
01-19 18:37:17.315: ERROR/AndroidRuntime(197): ... 11 more
01-19 18:37:17.375: ERROR/dalvikvm(197): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
for a template on tabview that will work out of the box. Your manifest seems ok (but I'm not that good at android yet), so I would suggest using logcat to figure out what's up. In Eclipse, Window > Show View > Other.. and Under Android select logcat. Now run your app again and watch the ouptut of logcat for errors. It is a very good way to debug your app, just look for red exceptions and follow the ones related to your source code.
精彩评论