1
我想使用片段製作標籤(使用工廠內容)。目前,在點擊每個標籤時,顯示的內容是「帶標籤的標籤內容:(標籤)」。請在這裏指導我。如何使用片段製作標籤(工廠使用內容)?
這是我的項目:http://www.filedropper.com/androiduxframework
,這是我的logcat:
12-26 13:06:51.768: D/AndroidRuntime(485): Shutting down VM
12-26 13:06:51.778: W/dalvikvm(485): threadid=1: thread exiting with uncaught exception (group=0x40015560)
12-26 13:06:51.808: E/AndroidRuntime(485): FATAL EXCEPTION: main
12-26 13:06:51.808: E/AndroidRuntime(485): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androiduxframework.pragya/com.androiduxframework.pragya.FirstActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.os.Looper.loop(Looper.java:123)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-26 13:06:51.808: E/AndroidRuntime(485): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 13:06:51.808: E/AndroidRuntime(485): at java.lang.reflect.Method.invoke(Method.java:507)
12-26 13:06:51.808: E/AndroidRuntime(485): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-26 13:06:51.808: E/AndroidRuntime(485): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-26 13:06:51.808: E/AndroidRuntime(485): at dalvik.system.NativeStart.main(Native Method)
12-26 13:06:51.808: E/AndroidRuntime(485): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-26 13:06:51.808: E/AndroidRuntime(485): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.Activity.setContentView(Activity.java:1657)
12-26 13:06:51.808: E/AndroidRuntime(485): at com.androiduxframework.pragya.FirstActivity.onCreate(FirstActivity.java:14)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-26 13:06:51.808: E/AndroidRuntime(485): ... 11 more
12-26 13:06:51.808: E/AndroidRuntime(485): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.androiduxframework.Tabs: make sure class name exists, is public, and has an empty constructor that is public
12-26 13:06:51.808: E/AndroidRuntime(485): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
12-26 13:06:51.808: E/AndroidRuntime(485): ... 20 more
12-26 13:06:51.808: E/AndroidRuntime(485): Caused by: java.lang.ClassNotFoundException: com.androiduxframework.Tabs in loader dalvik.system.PathClassLoader[/data/app/com.androiduxframework.pragya-2.apk]
12-26 13:06:51.808: E/AndroidRuntime(485): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-26 13:06:51.808: E/AndroidRuntime(485): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-26 13:06:51.808: E/AndroidRuntime(485): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-26 13:06:51.808: E/AndroidRuntime(485): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
12-26 13:06:51.808: E/AndroidRuntime(485): ... 23 more
12-26 13:06:54.688: I/Process(485): Sending signal. PID: 485 SIG: 9
待辦事項幫我糾正錯誤。 謝謝! :)
謝謝!它幫助了很多。但是我收到錯誤。這是我的項目:http://www.filedropper.com/androiduxframework 而我編輯我的問題添加logcat。幫助。謝謝! – phoenix
您在firstactivity.xml佈局中設置了錯誤的類名,將其更改爲class =「com.tabfragment.TabsFragment」 – Talha
謝謝!根據我的項目,將類更改爲「com.androiduxframework.pragya.TabsFragment」工作。 但輸出不正確。沒有選項卡被創建。只有第一個選項卡上的指示器(此處的「人員」)被打印爲文本。 – phoenix