所以在这里我从共享首选项文件加载我的数组,然后制作一个适配器并尝试将其设置到我的 widgetlistview 列表中。我不明白我如何使用我制作的适配器(ListAdapter),因为 setRemoteAdapter 不像在主应用程序 Activity 中那样接收适配器。我对 Android 相当陌生,所以我确信我错过了一些明显的东西,有人可以帮助我吗?
sharedprefs = context.getSharedPreferences(filename,0);
Index = sharedprefs.getInt("index", -1);
for (int IndexNum = 0; IndexNum < Index; IndexNum++){
LoadList(IndexNum);
}
ArrayAdapter<String> ListAdapter = new ArrayAdapter<>(context,R.layout.app_list_item, R.id.editdoublelistview_content,NicknamesW);
final RemoteViews v = new RemoteViews(context.getPackageName(),R.layout.widget);
v.setRemoteAdapter(R.id.WidgetListView,svcIntent);
最佳答案
我使用了我使用remoteviewsservice和.remoteviewsfactory发布的github链接中的示例并使其正常工作
关于java - 尝试在小部件 ListView 上显示 arraylist<string>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37983294/