I am trying to write a small application in Android. My application is on Widgets. I have a basic doubt on using RemoteViews. I found that whenever , I update some button or some UI layout a new object of the remoteviews is created . Will that be a problem with the performance? an example code is this:
http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html
updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_message);
even for updating the views everytime, new remoteview object is created. Please help me in understanding this.
You might consider creating only one object using singleton pattern. This can be done by implementing a singleton for your RemoteViews class and then using this singleton to create an object of RemoteViews. Actually the problem lies with the memory of the machine on which you are running the android app. If you are able to scale that up by doing some profiling and performance settings then you can very well create new objects using the above code. But if you have a limitation then I would suggest the singleton pattern. This solution assumes that the machine you are working on has enough processing power.
No it isn't a problem. I'm working with StackViewsWidget example to build a honeycomb widget that has a RemoteViews for each card in the deck of views that shuffle buy, and each card is recycled and rebuilt from what I can tell in the debugger, and it's smooth as butter flipping through the views on my Xoom.