20

I am making a widget for one of my applications which includes a ListView.

I want to display a list of 2 records on my widget. I have searched many forums and tutorials but could not find any tutorial on ListViews in widgets.

Can any one provide me with some good code/tutorials from where i can learn to implement ListViews in Android Widgets.

Sam
  • 7,252
  • 16
  • 46
  • 65
Shah
  • 4,990
  • 10
  • 48
  • 70
  • try this ([adding views to linearlayout][1]) [1]: http://stackoverflow.com/questions/4078039/remoteview-addview-not-working – Martin Nov 27 '13 at 21:03

2 Answers2

21

CommonsGuy has a sample widget application in GitHub using a ListView in a homescreen widget: LoremWidget

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
ddewaele
  • 22,363
  • 10
  • 69
  • 82
  • That example seems not to run on my Droid Bionic – IgorGanapolsky May 01 '12 at 15:39
  • 1
    i am using LoremWidget right now. how can i get a refernce to the listview there? getListView() does nothing :/ – bofredo Oct 17 '13 at 10:30
  • that sample now has properly specified its min sdk as 11 (3.x) https://github.com/commonsguy/cw-advandroid/commit/e0d2dde51bb651500a5b84fcd2c30c70e0dd4404 – larham1 Nov 21 '13 at 00:05
  • I tried to use this, but I got problems. I tried to discribe them: http://stackoverflow.com/questions/31713373/listview-in-widget-adds-randomly-items-on-scrolling-and-resizing – maysi Aug 08 '15 at 00:55
-1

Bit late in the day but I've just done this using 3 horizontal linearlayouts within a vertical ll. Set each of the horizontal lls to visibility GONE and then just set visibility to VISIBLE and set text for each one you want to show

Doesn't use a listview but achieves the same end.

Doug Conran
  • 437
  • 1
  • 5
  • 17