James, To modify the widget layout from an activity or service you should use some could like this:
RemoteViews rv = new RemoteViews(context.getPackageName(), WIDGET); rv.setTextViewText(R.id.label1, "text for label1"); rv.setTextViewText(R.id.label2, "text for label2"); rv.setTextViewText(R.id.label3, "text for label3"); ComponentName cn = new ComponentName(context, YourActivity.class); AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.updateAppWidget(cn, rv); As you can see in the example (written on the fly so not sure that it is 100% correct) you can edit multiple view-object in just one RemoteViews object. Don't start using different RemoteViews for each object on the view you want to edit cause you will run into problems with the updating right then. Also, have a look at the RemoteViews class to see what you can exactly do with it, don't know if you can make things visible or invisible with it. Although whatever that you want to edit with the RemoteViews should already being declared in the layout.xml file of your widget if I'm not wrong! Kostya, as far as I know that is not possible. You should then just create different widgets with the XML configuration file and perhaps you can reuse the widget provider class you have to implement so that you can share the logic for both widgets (if the content of both widgets is the same off cours.) On 29 mei, 10:42, Kostya Vasilyev <[email protected]> wrote: > James, > > I don't have the answer, but I would like to amend your question. > > Switching views is one thing, but what if there are versions of the same > widget that have different sizes? > > Minimal widget size is specified in res/<widget>.xml, using > <appwidget-provider minWidth & minHeight>. Is it posible to specify > different sizes depending on what widget version the users selects in my > configuration activity (or some other way)? > > I know it works with HTC Sense for its own widgets (e.g. clock, > weather...), but they might have changed Android to allow for this. > > Is there a way to do it with stock Android firmware? > > -- Kostya > > 2010/5/28 James W <[email protected]> > > > > > I suspect the answer is no, but it only seems possible at the moment > > to update an AppWidget via a RemoteViews object which is inflated from > > a static XML file. > > > Is there any way to build a RemoteViews object on the fly, or edit the > > layout of one that is already there? > > > The requirement is that I dont know until runtime exactly how many > > ImageViews I want to display in my AppWidget. > > > Currently I am setting all the ImageViews I may need in the layout XML > > file as invisible and then just making the ones I want visible, but am > > I then limited to what I have in the XML file to start with. It would > > be far more convenient to be able to just add the ones I need on the > > fly, and set their properties when updating. > > > Anyone know if there is a way to do that? > > > Thanks > > James > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%2Bunsubs > > [email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

