Android widgets



dan mentioned the idea of usingwidgets to bring our sunshine data directly to the user's home screen. what exactly is a widget? so far, we've only focused onactivities, full screen experiences, and fragments, which are reusableportions of those activities.


Android widgets, widgets differ in that areaprovides just the view. that view is then passedto the home screen app, the launcher to display alongside otherwidgets and other app launcher icons. app widgets had a humble beginning.


fixed-size widgets that couldrespond to one action, tapping. it was great for control widgets or widgets with just a single pieceof information to display. in android 3, widgets got support forcollections of data and vertical swiping. now, you can display a stack, list,or grid of data right in your widget, making it easy to jump into exactlythe piece of information you need. android 3.1 opened up the possibilityof resizing your widget either horizontally, vertically, or both.


this gave users the ability to customizeexactly how much space they want to give to your widget, andgave developers the tools needed to customize how they display their datadepending on the size of the widget. so, can we use these capabilities forsunshine? let's focus on two common cases. today's weather, where we'll builda horizontally resizable widget, showing information just about today.


Android widgets

and the weather forecast,where we'll build a detail widget, which will display the same data wesee in the main screen of sunshine,


to give users quick access to theirforecast, right from the home screen. so let's get started.


Android widgets Rating: 4.5 Diposkan Oleh: PaduWaras