gpt4 book ai didi

android - 在appwidget中输入

转载 作者:行者123 更新时间:2023-11-29 14:04:43 27 4
gpt4 key购买 nike

appwidget 获取输入的最佳方式是什么? .我知道我可以使用 setOnClickPendingIntent方法来自 RemoteViews ,但我不想要那个!有没有其他方法?附言当我尝试注册时 onClick Xml 中的监听器 ( <ImageView android:onClick="myHandler" ... /> ) 抛出异常。

W/AppWidgetHostView(  178): android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.Button
W/AppWidgetHostView( 178): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
W/AppWidgetHostView( 178): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
W/AppWidgetHostView( 178): at android.widget.RemoteViews.apply(RemoteViews.java:900)
W/AppWidgetHostView( 178): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:208)
W/AppWidgetHostView( 178): at com.htc.launcher.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:116)
W/AppWidgetHostView( 178): at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:243)
W/AppWidgetHostView( 178): at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:72)
W/AppWidgetHostView( 178): at android.os.Handler.dispatchMessage(Handler.java:99)
W/AppWidgetHostView( 178): at android.os.Looper.loop(Looper.java:123)
W/AppWidgetHostView( 178): at android.app.ActivityThread.main(ActivityThread.java:4595)
W/AppWidgetHostView( 178): at java.lang.reflect.Method.invokeNative(Native Method)
W/AppWidgetHostView( 178): at java.lang.reflect.Method.invoke(Method.java:521)
W/AppWidgetHostView( 178): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
W/AppWidgetHostView( 178): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
W/AppWidgetHostView( 178): at dalvik.system.NativeStart.main(Native Method)
W/AppWidgetHostView( 178): Caused by: java.lang.reflect.InvocationTargetException
W/AppWidgetHostView( 178): at android.widget.Button.<init>(Button.java:65)
W/AppWidgetHostView( 178): at java.lang.reflect.Constructor.constructNative(Native Method)
W/AppWidgetHostView( 178): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
W/AppWidgetHostView( 178): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
W/AppWidgetHostView( 178): ... 19 more
W/AppWidgetHostView( 178): Caused by: java.lang.IllegalStateException: The android:onClick attribute cannot be used within a restricted context
W/AppWidgetHostView( 178): at android.view.View.<init>(View.java:2005)
W/AppWidgetHostView( 178): at android.widget.TextView.<init>(TextView.java:335)
W/AppWidgetHostView( 178): at android.widget.Button.<init>(Button.java:69)
W/AppWidgetHostView( 178): ... 23 more

最佳答案

I know that I can use setOnClickPendingIntent method from RemoteViews, but I don't want that!

你别无选择。这是通过 API 级别 10( Gingerbread )的唯一输入选项。

对于 API 级别 11 及更高级别(Honeycomb 等),您可以创建包含 ListViewGridViewStackView 的应用小部件.对于这些,您可以提供另一个 PendingIntent,它将在单击列表(或网格或堆栈)中的项目时调用。这与 setOnClickPendingIntent() 的工作方式类似。

关于android - 在appwidget中输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7714644/

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