8

does anyone know how to build that kind of tabs that the "News and Weather" app uses?

see here http://img51.imageshack.us/img51/8788/tabsd.png

This means a tab area that can be scrolled to the left & right. Changing the tabs is also possible by scrolling the listview to the left / right.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
nr1
  • 133
  • 2
  • 6
  • 9
    Unfortunately, that specific code is not part of the Android SDK, nor is that application part of the open source project. I had a conversation with a Googler about that specific feature, and it is apparently quite difficult to implement and even tougher to genericize. With luck, someday they will release that app as open source or perhaps make a generic widget as part of the Android SDK. – CommonsWare Dec 19 '10 at 16:10
  • I _think_ it might be easier to solve this problem with fragments. So, try it on Honeycomb or wait for the fragment backport. – Szabolcs Berecz Feb 22 '11 at 17:01
  • Would it be possible to use some form of "gestures" to detect screen swiping? – Jimmy Feb 22 '11 at 17:26

3 Answers3

2

That component up there is actually a HorizontalScrollView, with buttons inside. Use it like a LinearLayout and throw in the buttons. You'll have to manually handle the selected/unselected states of the buttons/tabs though.

zrgiu
  • 6,200
  • 1
  • 33
  • 35
1

The tabs are quite easy to create, it's an horizontal scroll view with buttons as someone else already mentioned. The content part is the tough thing. It scrolls both horizontally and vertically, therefore requires some magic.

Sven Haiges
  • 2,636
  • 5
  • 42
  • 54
1

Once you have the tabs, you can use an adaptation of WorkspaceView for the rest: Horizontal "tab"ish scroll between views

EDIT: This is now supported in the Android SDK. See here: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html?m=1

Community
  • 1
  • 1
Jon O
  • 6,532
  • 1
  • 46
  • 57