gpt4 book ai didi

Android自定义小部件膨胀异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:58:37 25 4
gpt4 key购买 nike

XML

  <?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

最佳答案

我遇到了同样令人困惑的问题。要修复它,您的自定义 View 应该提供一个带有两个参数的构造函数:建议的 Context 和 AttributeSet here .

关于Android自定义小部件膨胀异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5036273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com