I create widget for Android application (in Java, of course). I have classic RemoteViews created from layout (using layout id)
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.view);
and I need edit or change view (identify by id). In classic View is it easy, using findViewById function.
View v = ... //inflate layout R.layout.view
View my = v.findViewById(R.id.myViewId);
processView(my); //filling view
But it is not supported in RemoteViews. Is possible get view using apply(), but after processView and reapply() I not see changes in view.
View v = rv.apply(context, null);
View my = v.findViewById(R.id.myViewId);
processView(my); //this work's fine
rv.reapply(context,my);
Second, worse option, is get my required view form RemoteViews, process it, delete old view and add processed new view using addView().
RemoteViews rv = ...
View my = ... //apply, find and process
//remove old view
RemoteViews rvMy = ... //create RemoteViews from View
rv.addView(rvMy)
But I don't know how create RemoteViews from View (it is possible?). Any ideas how solve this problem?
Try this way :
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widget);
remoteViews.setTextViewText(R.id.widget_textview, text); <---- here you can set text
// Tell the widget manager
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
Here is a useful post to understand widget behaviour :
http://www.vogella.com/articles/AndroidWidgets/article.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With