Hi Dirk

I dont have a problem with updating my widget, either setting text,
visibility or intents on all the different imageviews, textviews etc
within my widgets whenever i want all works fine.

The issue is more fundamental than that: the remote views object is
inflated from a static compiled XML file in the contructor:

      RemoteViews (String packageName, int layoutId)

I want to know if it is possible to build a remote views object in
some other way than from the XML file, because I dont know until run
time exactly how I want to lay out my RemoteView.

Ideally I would like to be able to create a blank remote views object,
then add items such as layouts, imageviews and text views to it
dynamically.

The only other contstructor available is
      RemoteViews (Parcel parcel)

But it is not clear if that will do what I want, I need to look into
Parcel to see what it is used for.


Kostya,

HTC do it in Sense because they have their implemented the own home
screen; whilst it can host normal AppWidgets, they have written
special HTC widgets which are not standard AppWidgets at all, but
greatly customised to work with their home screen. Hence they can
support animation, touch scrolling etc.

They have also customised how the user adds these special widgets,
which is why you can have multiple options for Clocks, Calendars etc
under a single Clocks or Calendars heading.

In normal Android, you have to build an AppWidget for every size you
want, and specify the size beforehand.

I would love to get hold the HTC homescreen API, so many cool things
there...




On May 29, 5:12 pm, Dirk Vranckaert <[email protected]> wrote:
> 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- Hide quoted text -
>
> - Show quoted text -

-- 
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

Reply via email to