Scrollable TabHost

Quickly share your Android Code Snippets here...

Scrollable TabHost

Postby honcheng » Wed Dec 16, 2009 1:14 pm

This is my first open source project. It's a scrollable TabHost.
I put this in code snippet because it isn't exactly a full app. Just a widget for developers to integrate into their application

http://bit.ly/7DWtjt

[youtube]http://www.youtube.com/watch?v=Aq8Tbcp8mQs[/youtube]
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Top

Postby achie1266 » Fri Dec 18, 2009 8:21 am

Thank you.
It looks so promising.

I was searching for something like this at one point and could not find one.
will check it out soon
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby honcheng » Fri Dec 18, 2009 8:59 am

Let me know if you have any suggestions, or if you like to contribute updates to the projects.

Next time I'll do it probably to give devs the option to turn on/off the scrollview. If scrollview is off, it'll group the buttons in the non-visible region and put it as a the last button as a list, just like iPhone.
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby Boni2k » Thu Dec 31, 2009 5:45 pm

Hello honcheng,
its a nice thing, relatively easy to adopt in my application.
I have one question left: I click on one tab which loads up a new Activity. This activity contains a ListView and in case I click on one ListItem it should switch to an other tab. How could I achieve this? In other words: How to access the tabs from a class that does not extend ScrollableTabActiviy?

Thank you!
Boni
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby achie1266 » Thu Dec 31, 2009 6:04 pm

you may try making the TabHost as a static variable and then access it from the other class and use setCurrentTab method there.
in your class[MyTabActivity] that extends TabActivity
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. static TabHost mTabHost;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
And then in your other activity
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MyTabActivity.mTabHost.setCurrentTab(i);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
I never tried it though but I do not see why it should not work. :D
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby Boni2k » Thu Dec 31, 2009 7:29 pm

TabHost? I used to try this on ScrollableTabActivity :-)

Thank you anyway, I'm sure I'm gonna need this knowledge elsewhere!
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Top

Postby honcheng » Sun Jan 10, 2010 11:20 pm

Boni2k wrote:Hello honcheng,
its a nice thing, relatively easy to adopt in my application.
I have one question left: I click on one tab which loads up a new Activity. This activity contains a ListView and in case I click on one ListItem it should switch to an other tab. How could I achieve this? In other words: How to access the tabs from a class that does not extend ScrollableTabActiviy?

Thank you!
Boni


I'm not sure hoe to call methods available in the previous activity. I assume the activity group I'd considered the previous activity n the currently display activity is the current. The only way I can think of is using broadcastreceivers. Tried it n works. Will commit soon. I don't think it's the best solution. Let me know if you know any
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby honcheng » Mon Jan 11, 2010 9:17 am

Boni2k wrote:Hello honcheng,
its a nice thing, relatively easy to adopt in my application.
I have one question left: I click on one tab which loads up a new Activity. This activity contains a ListView and in case I click on one ListItem it should switch to an other tab. How could I achieve this? In other words: How to access the tabs from a class that does not extend ScrollableTabActiviy?

Thank you!
Boni


Hi,
check the latest commit I made. I have made this function available. You can compile and look at the demo.
I am not sure what is the best way for the Activity to communicate with the ActivityGroup, so I used BroadcastReceiver. May not be the best way.
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby Boni2k » Mon Jan 11, 2010 1:34 pm

Thanks a lot, works fine! Just what I wanted :-)
Just two little thing left:

1. Demo Scrollable TabHost3 seems to ignore any title, is that on purpose?
2. In line 88 of TabBarButton.java and in line 79 of RadioStateDrawable.java there is R.drawable.bottom_bar_highlight mentioned. I guess it's just like the background oh the Tabbar from the iPhone if it's activated. This looks pretty neat but I did not find a way to make use of this.

If my tabicon would have a title (1.) and this background (2.) it would be awesome.

Greetings!
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby honcheng » Mon Jan 11, 2010 2:26 pm

Boni2k wrote:Thanks a lot, works fine! Just what I wanted :-)
Just two little thing left:

1. Demo Scrollable TabHost3 seems to ignore any title, is that on purpose?
2. In line 88 of TabBarButton.java and in line 79 of RadioStateDrawable.java there is R.drawable.bottom_bar_highlight mentioned. I guess it's just like the background oh the Tabbar from the iPhone if it's activated. This looks pretty neat but I did not find a way to make use of this.

If my tabicon would have a title (1.) and this background (2.) it would be awesome.

Greetings!


you must have gone through the code thoroughly. Those are bugs.
If I remove the background image, it somehow causes title not rendered fully. The one without title is also a known bug. I'm not sure what's the problem yet.

Are u familiar enough with android to fix that?
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby honcheng » Mon Jan 11, 2010 2:27 pm

Boni2k wrote:Thanks a lot, works fine! Just what I wanted :-)
Just two little thing left:

1. Demo Scrollable TabHost3 seems to ignore any title, is that on purpose?
2. In line 88 of TabBarButton.java and in line 79 of RadioStateDrawable.java there is R.drawable.bottom_bar_highlight mentioned. I guess it's just like the background oh the Tabbar from the iPhone if it's activated. This looks pretty neat but I did not find a way to make use of this.

If my tabicon would have a title (1.) and this background (2.) it would be awesome.

Greetings!


you must have gone through the code thoroughly. Those are bugs.
If I remove the background image, it somehow causes title not rendered fully. The one without title is also a known bug. I'm not sure what's the problem yet.

Are u familiar enough with android to fix that?
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby Boni2k » Mon Jan 18, 2010 9:22 am

honcheng wrote:you must have gone through the code thoroughly. Those are bugs.
If I remove the background image, it somehow causes title not rendered fully. The one without title is also a known bug. I'm not sure what's the problem yet.

Are u familiar enough with android to fix that?

Hello,
actually I'm still not too familiar with it. Though I will try to fix it this day by myself. But I'm not too confident that I can fix it. It would be the last thing I want - I will soon release my application. It's an application for a german community called "KWICK!". This is the current state: http://www.youtube.com/watch?v=PyMao5HNSXI

Many greetings, Jonas
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby honcheng » Mon Jan 18, 2010 9:28 am

Boni2k wrote:
honcheng wrote:you must have gone through the code thoroughly. Those are bugs.
If I remove the background image, it somehow causes title not rendered fully. The one without title is also a known bug. I'm not sure what's the problem yet.

Are u familiar enough with android to fix that?

Hello,
actually I'm still not too familiar with it. Though I will try to fix it this day by myself. But I'm not too confident that I can fix it. It would be the last thing I want - I will soon release my application. It's an application for a german community called "KWICK!". This is the current state: http://www.youtube.com/watch?v=PyMao5HNSXI

Many greetings, Jonas


It looks a bit odd in the video. When you click on a button, it turns green, but momentarily turns gray again. It does not happen in the demo. Is that what you want? Or is it another bug?
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Postby Boni2k » Mon Jan 18, 2010 10:09 am

Hey,
I'm not sure about it. But I didn't edited it to act like this. It turns grey when a ProgressDialog is called and turns green again when it disappears. But that's not too disturbing :-)
Jonas
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby honcheng » Mon Jan 18, 2010 10:15 am

Boni2k wrote:Hey,
I'm not sure about it. But I didn't edited it to act like this. It turns grey when a ProgressDialog is called and turns green again when it disappears. But that's not too disturbing :-)
Jonas


it feels like a bug, which it is :)
just to check again, if the page loads without progressdialog, it doesn't blink like that?
honcheng
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 16, 2009 1:09 pm

Top
Next

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 4 guests