android - RemoteViews id in loops? -
i've pretty given on dynamic remoteviews, still have 20 remoteviews 3-4 method calls on each in onupdate method. problem is, can have iterator on remoteviews subview id loop?
edit ok, here's code, tried using bookmarkcounter iterator since r class generates r.id.widget* * incrementing number (by one). doesn't work.
@override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { cursor cursor; string sort_by_column = constants.sort_by_column; string sort_order = constants.sort_order; int bookmarkidcounter = r.id.widget_bookmark_1; bitmap bitmap; hashmap<integer, string> urls = new hashmap<integer, string>(); componentname thiswidget = new componentname(context, widgetprovider.class); remoteviews updateviews = new remoteviews( context.getpackagename(), r.layout.widget_main); remoteviews bookmarks = new remoteviews( context.getpackagename(), r.layout.widget_bookmarks);; cursor = context.getcontentresolver().query( browser.bookmarks_uri, constants.projection, constants.selection, null, sort_by_column + " " + sort_order); if(cursor.movetofirst()) { bytearrayinputstream blobimage; do{ blobimage = new bytearrayinputstream( cursor.getblob(cursor.getcolumnindex(bookmarkcolumns.favicon))); bitmap = bitmapfactory.decodestream(blobimage); bitmap = bitmap.createscaledbitmap( bitmap, constants.favicon_size, constants.favicon_size, false); bookmarks.setimageviewbitmap(bookmarkidcounter, bitmap); bookmarks.setint(bookmarkidcounter, "setbackgroundcolor", color.white); urls.put(bookmarkidcounter, cursor.getstring( cursor.getcolumnindex(bookmarkcolumns.url))); bookmarkidcounter++; } while (cursor.movetonext() && (bookmarkidcounter < 2)); } updateviews.addview(r.id.widget_main_container, bookmarks); cursor.deactivate(); appwidgetmanager.updateappwidget(thiswidget, updateviews); }
remoteviews not view nor contain views.
it way "describe" view , have created in other process. it's set of actions must performed build view.
as there no views inside there no way retrieve/iterate list of subviews.
Comments
Post a Comment