Android 如何在appwidget中将自定义ListAdapter设置为列表视图?
我有一个列表视图。我需要为每个列表项创建一个自定义视图,因此我创建了一个自定义ListAdapter,它提供了视图,下面给出了视图的布局。但是如何使用RemoteView将此listAdapter设置为小部件中的ListViewAndroid 如何在appwidget中将自定义ListAdapter设置为列表视图?,android,android-listview,android-adapter,remoteview,Android,Android Listview,Android Adapter,Remoteview,我有一个列表视图。我需要为每个列表项创建一个自定义视图,因此我创建了一个自定义ListAdapter,它提供了视图,下面给出了视图的布局。但是如何使用RemoteView将此listAdapter设置为小部件中的ListView <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:layout_margin="1sp"
android:padding="10sp"
>
<TextView
android:id="@+id/widgetInfo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/listItemDummy"
android:textColor="@android:color/black"
/>
<TextView
android:id="@+id/widgetInfo2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/listItemDummy"
android:textColor="@android:color/black"
/>
</LinearLayout>
而不是通用的
适配器
,对于远程视图
,您需要实现。要为每个项目返回自定义的RemoteView
(是,RemoteView
,而不是View
),您需要覆盖其方法
另外,对于RemoteView
s,您不需要setAdapter()
,您需要提供一个将在RemoteViewsFactory
上方返回到其客户端的
最后,向要显示RemoteView
s的客户端传递此服务的Intent
您需要在清单文件中声明服务及其意图。这将使您的应用程序成为其他应用程序或任何远程进程的远程列表视图的提供者。您希望此列表视图使用listadapter还是远程视图使用listadapter?还有,您尝试了什么?我想将ListView添加到一个小部件中,该小部件具有自定义视图项。这是我的基本要求,所以我创建了一个listAdapter,但您似乎无法使用普通的listAdapter并在小部件中添加到ListView。。上面的布局是针对列表中的单个视图项…您是否建议这样的内容:remoteViewsServiceIntent=new Intent(上下文,MyRemoteViewsService.class)@阿莫坎贝尔