subitems subitem studio item con android listview notifications remoteview

android - subitem - ¿Cómo crear Listview con ayuda de Remote View?



item subitem listview android (2)

Ya había intentado con la solución de @iDroid Explorer desde una de sus respuestas anteriores. Pero listview no aparecía en el panel de borde (PD: quería que esto se implementara en el panel de borde de la nota de galaxy).

Así que probé el código siguiente:

private RemoteViews updateWidgetListView(Context arg0, int i) { //which layout to show on widget RemoteViews remoteViews = new RemoteViews(arg0.getPackageName(), R.layout.activity_main_sub); //RemoteViews Service needed to provide adapter for ListView Log.d("fff", "updateWidget: "+ i); Intent svcIntent = new Intent(arg0, MyService.class); //passing app widget id to that RemoteViews Service svcIntent.putExtra("Id", i); Log.d("fff", "receiver:"+appnM); svcIntent.putExtra("appname", appnM); //setting a unique Uri to the intent //don''t know its purpose to me right now svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME))); //setting adapter to listview of the widget remoteViews.setRemoteAdapter(i, R.id.list_icon,svcIntent); // remoteViews.setRemoteAdapter(i, svcIntent); arg0.startService(svcIntent); //setting an empty view in case of no data remoteViews.setEmptyView(R.id.list_icon, R.id.empty_view); Log.d("fff","end of myReceiver"); return remoteViews; }

Y en mi clase de servicio he llenado los elementos necesarios en la lista.

Recibí ayuda de un ejemplo llamado: WidgetListView1, que encontré en búsquedas aleatorias.

Estoy tratando de hacer una vista de lista dinámica en el widget con la ayuda de remoteview , ya que quería esta lista de iconos de aplicaciones en un widget. Quiero mostrar las notificaciones entrantes de todas las aplicaciones que están separadas de la aplicación. Quiero crear una lista permanente de notificaciones y cuando el usuario haga clic en el icono de la aplicación desde la vista de lista, se mostrará esa notificación en particular. Estoy usando API 19 para obtener todas las notificaciones y también tuve éxito, pero no sé cómo puedo crear Listview en Widget con Remoteview y también con drawables(Icons) .


¿Ha buscado o intentado con otros ejemplos que tengan ListView en el widget? Por favor, consulte la demostración de Weather Widget disponible en github.

Código:

public class MyWidgetProvider extends AppWidgetProvider { private static HandlerThread sWorkerThread; private static Handler sWorkerQueue; public MyWidgetProvider() { // Start the worker thread sWorkerThread = new HandlerThread("MyWidgetProvider-worker"); sWorkerThread.start(); sWorkerQueue = new Handler(sWorkerThread.getLooper()); } public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i = 0; i < appWidgetIds.length; ++i) { ... final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); views.setRemoteAdapter(R.id.lvWidget, svcIntent); sWorkerQueue.postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub views.setScrollPosition(R.id.list, 3); appWidgetManager.partiallyUpdateAppWidget(appWidgetIds[i], views); } }, 1000); appWidgetManager.updateAppWidget(appWidgetIds[i], views); ... } } }

Que se comportará como a continuación:

Verifique el proyecto github y el código de ejemplo anterior.