You can set an attribute only before view's inflation. After view has
been inflated, the only thing you can resort to is calling view's
method that will change its state. Right now, methods offered by
RemoteViews is the only way to communicate with widget. I think you
can help us solve your problem if you'd explain in more details what
exactly are you to do.

On Oct 2, 1:17 am, android learner <android.lear...@gmail.com> wrote:
> Thanks Paul. That was helpful. In my case, the public method I'm
> trying to call, does not match with
> the signature of any of the methods that RemoteView class offers. I
> guess that explains the error I get.
> Is there any way to overcome this limitation? Also, I'd like to know
> if there is any other way to
> dynamically set an xml attribute through remote view (where none of
> the RemoteView methods support setting this attribute)
>
> Thanks
>
> On Oct 1, 4:47 pm, Paul Turchenko <paul.turche...@gmail.com> wrote:
>
> > Yes, you can call a public method on widget's views via the remote
> > views as long as it matches signature of 1 of methods that RemoteViews
> > class offers. For example, to set text on the TextView that exists in
> > widget's layout, you can use RemoteViews.setString(R.id.your_view_id,
> > "setText", "your widget text") or RemoteViews.setTextViewText
> > ((R.id.your_view_id, "your widget text"). Both are equal, but first
> > one uses reflection.
>
> > On Oct 2, 12:04 am, android learner <android.lear...@gmail.com> wrote:
>
> > > Let us keep aside the fact that I'm using a custom view. Consider a
> > > normal case,
> > > where I am using an existing Android view, for example AnalogClock
> > > class in my layout. Is there anyway I can call a public method
> > > of AnalogClock Class through the remote view? I need to dynamically
> > > update something in the AnalogClock and that needs to be reflected in
> > > the remote view. Any help would be really appreciated.
>
> > > Thanks
>
> > > On Oct 1, 1:14 pm, android learner <android.lear...@gmail.com> wrote:
>
> > > > Thanks Mark. Yes it is my own view class (like a button). But it works
> > > > fine in RemoteView as long as I do not attempt to "set"
> > > > anything in my view class. But one of the parameters in this view
> > > > class is dynamic and I need to set it from the Remote View (like we do
> > > > a setText for a button). That is where I am stuck at. I have a public
> > > > method in my view class which takes a string parameter and I somehow
> > > > need to call that method through the remote view.
>
> > > > Thanks
>
> > > > On Oct 1, 1:02 pm, "Mark Murphy" <mmur...@commonsware.com> wrote:
>
> > > > > >     Can some one please help me understand the setString function in
> > > > > > RemoteViews?
> > > > > > public void  setString  (int viewId, String methodName, String 
> > > > > > value)
>
> > > > > > Can I pass any method name to setString ? I have a custom view in my
> > > > > > xml layout file. I'm passing the view id of my custom view, name of 
> > > > > > a
> > > > > > method in my custom view class and a string parameter for the 
> > > > > > method.
> > > > > > It doesn't seem to be working. Is there is a limitation on the 
> > > > > > methods
> > > > > > that can be passed to setString? Or is there something fundamentally
> > > > > > wrong in what I'm doing?
>
> > > > > You can't have a custom view in a layout managed by RemoteViews, 
> > > > > assuming
> > > > > that by "custom view" you mean your own separate class.
>
> > > > > --
> > > > > Mark Murphy (a Commons Guy)http://commonsware.com
> > > > > Android App Developer Books:http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to