I was inspired by the simple TabHost/TabWidget demonstration by Jeffrey Sharkey, and decided to expand upon it significantly. In my demo, I have replaced all the default drawables and layouts, created my own custom ColorStateList, and even utilized TabActivity for greater isolation.
Download: TabActivityDemo.tar.gz
The code and images for this demo are in the public domain, so please feel free to use and modify as you wish.
NOTE: TabActivity is currently marked as deprecated, but according to this post, I believe that may be in error.
Subscribe to:
Post Comments (Atom)
13 comments:
thank you very much for posting this example. I think it'll end up saving me a lot of guesswork.
I'm running into problems. Whenever I select a tab (be it with setting a default or not but then clicking, I get a NullPointerException in TabHost$IntentContetStrategy.getContentView
Any idea what's up? I wouldn't mind showing you my code if you'd be so kind as to take a look
I suppose, but I would first start by attaching a debugger (such as the one built into Eclipse) to your project and trapping the NullPointerException. Also, look at the output of adb logcat.
Someone can do something similar with sdk1 ?
Everything's possible. Please see my post here:
http://tourizo.blogspot.com/2009/02/android-tabactivity-customization.html
It looks like they changed the API again; your example won't compile. I'll use it for inspiration, though.
Just wanted to say thanks for the demo. Saved me a lot of time!!
very good post...thanks for the useful info
Thanks for it.. Very helpful.. thanks again..
Many thanks for the code. ViewInflate is no more in the SDK. Its replaced by LayoutInflater.
For the code to work in latest SDK, please replace MyIndicator class as:
public static class MyTabIndicator extends LinearLayout {
public MyTabIndicator(Context context, String label) {
super(context);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tab = inflater.inflate(R.layout.tab_indicator, this);
TextView tv = (TextView) tab.findViewById(R.id.tab_label);
tv.setText(label);
}
}
it is not showing that bottom bar in my emulator by default it showing one in the emulator
If this works it would be just amazing. After I imported the project there seems to be an error with it as it can't recognize ViewInflate type that you used in MyTabIndicator function.. Any suggestions?
Post a Comment