<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.org.BatteryManager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.org.BatteryManager.BatteryView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:textColor="#ffffffff"
/>
</LinearLayout>
02-17 18:49:49.392: WARN/AppWidgetHostView(124): updateAppWidget couldn't find any view, using error view
02-17 18:49:49.392: WARN/AppWidgetHostView(124): android.view.InflateException: Binary XML file line #9: Error inflating class com.org.BatteryManager.BatteryView
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.widget.RemoteViews.apply(RemoteViews.java:930)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:219)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:250)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:73)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.os.Looper.loop(Looper.java:123)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at java.lang.reflect.Method.invoke(Method.java:521)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at dalvik.system.NativeStart.main(Native Method)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): Caused by: java.lang.ClassNotFoundException: com.org.BatteryManager.BatteryView in loader dalvik.system.PathClassLoader[.]
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
02-17 18:49:49.392: WARN/AppWidgetHostView(124): ... 15 more
7
A
回答
0
什麼是com.org.BatteryManager.BatteryView?
如果你想使用自定義視圖,那麼它是可能的。實現它的方法是在Java中創建一個自定義視圖類,以擴展一些基本視圖組件類。
例如,我在很多應用程序中使用自定義圖庫組件。畫廊類只會在與默認行爲不同的滑動中左右移動一幀。
,我把我的自定義庫的方式是擴展了基本庫類 -
package com.testing.whatever;
public class CustomGallery extends Gallery {
//CODE OVERRIDES HERE
}
在我的XML代碼
然後,代碼看起來類似於你已經有 -
<com.testing.whatever.CustomGallery android:layout_width="fill_parent" android:layout_height="fill_parent" />
我懷疑你得到你的錯誤,因爲你還沒有編碼com.org.BatteryManager.BatteryView或它在你的java文件中的錯誤的地方。
+1
這不適用於應用程序小部件。應用程序小部件不能使用自定義類。 – CommonsWare 2012-11-12 17:35:23
6
相關問題
- 1. Android:自定義TextView膨脹異常
- 2. Android:膨脹異常
- 3. android膨脹異常
- 4. Android視圖膨脹異常?
- 5. 膨脹異常 - 錯誤膨脹textview
- 6. 自定義佈局需要膨脹xml小部件
- 7. 嘗試膨脹自定義視圖android
- 8. 膨脹自定義相對佈局時類拋出異常? 15:
- 9. Android異常:錯誤膨脹類片段
- 10. Android - 異常錯誤膨脹類com.facebook.drawee.view.SimpleDraweeView
- 11. 自定義控件:錯誤膨脹類
- 12. 錯誤膨脹。 ResourceNotFound異常?
- 13. 異常「膨脹類碎片」
- 14. ViewStub空的異常膨脹
- 15. Android:自定義控件/將XML膨脹到佈局上?
- 16. 如何使用膨脹版式訪問自定義DialogPreference中的小部件?
- 17. 如何膨脹自定義視圖類?
- 18. 錯誤膨脹類,自定義視圖
- 19. 問題膨脹自定義佈局
- 20. 自定義ViewGroup通過膨脹xml
- 21. 帶有自定義樣式的TextView導致奇怪的膨脹異常
- 22. 自定義視圖不會正常膨脹
- 23. Android:OnNewIntent在膨脹之前需要自定義視圖的大小
- 24. Android自定義小部件
- 25. IndexOutOfBoundsException異常的片段膨脹
- 26. 膨脹mapview第二次拋出異常
- 27. 捕獲異常膨脹的佈局
- 28. Android的:XML文件,膨脹
- 29. 如何讓這個android自定義對話框出現(膨脹)?
- 30. 從XML膨脹自定義視圖創建Illegalstateexception(Android,Java)
嘗試刪除@RemoteViews標記,如果你有一個,那對我有用。正在絞盡腦汁想出來。 – DeliveryNinja 2011-03-20 15:36:27