Android Tabs with Fragments

Evelina Vrabie

Dedicated coder, occasional blogger, hackathon goer and friendly team mate.

You may also read...

174 Responses

  1. My partner and I stumbled over here coming from a different page and thought I may as well check things out.
    I like what I see so now i’m following you.
    Look forward to finding out about your web page yet again.

    Feel free to visit my website; comparatif adsl

  2. Pretty! This has been an extremely wonderful
    post. Thank you for supplying these details.

  3. Nice blog here! Also your website loads up very fast!

    What web host are you using? Can I get your affiliate
    link to your host? I wish my website loaded up as quickly
    as yours lol

  4. If you start them all within the daily use of computer, you’ll
    obtain a slow running computer. In order to build these structures, you will require resources.
    To use this new resource, click on the start key.

  5. Hello to all, the contents existing at this web page are actually awesome for people knowledge, well, keep
    up the good work fellows.

    My weblog: making a Disney vacation magical

  6. I like the helpful info you provide for your articles.
    I will bookmark your weblog and take a look at again right here frequently.

    I am moderately certain I will learn plenty of new stuff right right here!
    Best of luck for the next!

  7. If you desire to take a great deal from this post then you
    have to apply such techniques to your won weblog.

  8. Attractive section of content. I just stumbled upon your weblog and in accession capital to
    assert that I get actually enjoyed account your blog
    posts. Anyway I will be subscribing for your augment
    or even I achievement you get admission to constantly quickly.

    my web page :: challenger garage door opener

  9. We are a bunch of volunteers and starting a brand new scheme in our community.
    Your site provided us with helpful information to work on. You’ve
    done an impressive activity and our entire neighborhood
    will likely be thankful to you.

  10. faster says:

    Hello to every one, the contents present at this
    site are truly amazing for people experience, well, keep up the nice
    work fellows.

  11. Hildegarde says:

    Excellent blog here! Additionally your site so much up fast!
    What web host are you using? Can I am getting your affiliate hyperlink for your host?
    I want my web site loaded up as fast as yours lol

  12. Aw, this was an extremely good post. Taking a few minutes
    and actual effort to produce a superb article… but what can I say… I procrastinate a
    whole lot and never seem to get anything done.

  13. Hello There. I found your blog using msn. This is an extremely well written article.
    I will make sure to bookmark it and return to read more of
    your useful info. Thanks for the post. I’ll certainly comeback.

  14. I will right away take hold of your rss as I caan not too find your
    email subscription hyperlink or e-newsletter
    service. Do you hzve any? Kindly allow me recognize in order that I may subscribe.
    Thanks.

    Also visit myy homepage:surfing puerto rico (todaysarticlewriter.com)

  15. A Pattek says:

    Hello my family member! I want to say that this post is
    awesome, great written and include approximately all significant infos.
    I would like to see extra posts like this .

    Here is my web site :: A Pattek

  16. Please let me know if you’re looking for a article author
    for your site. You have some really good posts and I believe I would be a good asset.
    If you ever want to take some of the load off, I’d love to write some content for your blog in exchange
    for a link back to mine. Please blast me an email if
    interested. Kudos!

    Look at my blog post … Torrance dui attorneys

  17. I am really thankful to the holder of this website who has shared
    this enormous piece of writing at at this time.

  18. Eduardo K says:

    Thanks! Nice post!

  19. Howdy! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly?
    My weblog looks weird when viewing from my apple iphone.
    I’m trying to find a template or plugin that might be able to fix this
    problem. If you have any suggestions, please share.
    Appreciate it!

  20. Pearline says:

    The Premier League has been topped by four teams Arsenal, Blackburn Rovers, Chelsea, and Manchester United since the league’s inception. Born from October 14 to 23 – Libra under the
    influence of Jupiter – born gourmand, sensual people, capable in literature, like ceremonies.
    is a positive energy stone and enhances concentration, persistence,.

  21. That is really attention-grabbing, You’re a very skilled blogger.
    I have joined your rss feed and stay up for in search of
    extra of your magnificent post. Also, I have shared your web site in my
    social networks

    my web page garage door opener repair

  22. Hi my friend! I wish to say that this article is amazing, nice written and come with almost all important infos.
    I would like to peer more posts like this .

    my web site: garage door repair

  23. I have read so many posts regarding the blogger lovers but
    this post is genuinely a fastidious piece of writing, keep
    it up.

    Review my page – garage door repair

  24. My brother suggested I might like this web site.

    He used to be totally right. This put up actually made my day.
    You can not consider simply how a lot time I had
    spent for this information! Thanks!

    Feel free to surf to my web-site – garage door repair

  25. all the time i used to read smaller articles or reviews
    that also clear their motive, and that is also happening
    with this paragraph which I am reading here.

    Here is my site: iphone garage door opener

  26. I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire someone to do it for
    you? Plz reply as I’m looking to create my own blog and would like to find out where u
    got this from. cheers

    Feel free to surf to my page … garage door opener

  27. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your weblog?
    My website is in the exact same area of interest as yours and my users would truly benefit from some of the information you present
    here. Please let me know if this okay with you.
    Thank you!

    Visit my blog; hacking software

  28. Thankfulness to my father who shared with me regarding this webpage, this blog is truly amazing.

    Feel free to surf to my web site homelink garage door opener

  29. This piece of writing will assist the internet viewers for creating new
    blog or even a weblog from start to end.

    My website … garage door repair

  30. Helpful info. Fortunate me I found your website accidentally, and
    I am stunned why this twist of fate did not took place earlier!
    I bookmarked it.

  31. Hi everyone, it’s my first pay a visit at this site, and piece of writing is truly fruitful designed for me, keep up posting
    these articles or reviews.

  32. Thanks for your personal marvelous posting! I definitely enjoyed
    reading it, you are a great author. I will make sure to bookmark
    your blog and will often come back from now on. I want to encourage one to continue your
    great posts, have a nice weekend!

    Feel free to visit my homepage; wendy stevens ft lauderdale

  33. Pick a licensed, bonded and insured service provider for garage door repairs to minimize risks
    encountered during repairs like errors, unprofessional technicians and poor workmanship.
    This type of fencing, sometimes called cyclone fencing, is widely used for security purposes
    as well as for creating playground enclosures, animal pens, and more.
    You may also decide to require the recipient’s signature on the return receipt as evidence that the landlord
    received the notice.

    my web-site … garage door repair Atlanta

  34. Right here is the perfect webpage for anyone who wishes to understand this topic.
    You understand so much its almost tough to argue with you (not
    that I really will need to…HaHa). You certainly put a new spin on a topic
    which has been written about for ages. Wonderful stuff, just great!

    Review my site – 24 hour emergency ac repair Solebury

  35. I like the valuable information you provide in your articles.
    I’ll bookmark your blog and test once more right here frequently.

    I’m rather certain I’ll learn plenty of new stuff right
    right here! Best of luck for the next!

    My site … click for more info

  36. Heya are using WordPress for your site platform? I’m new to the
    blog world but I’m trying to get started and create my own.
    Do you need any html coding knowledge to make your
    own blog? Any help would be really appreciated!

    My blog :: contractor surety bonds

  37. I do not even know how I stopped up right here, however I believed
    this put up used to be good. I do not understand who you
    are but definitely you’re going to a famous blogger for those who are not already.
    Cheers!

    my weblog back pain relief mesa az

  38. It’s amazing to pay a quick visit this website and reading the views of all friends regarding
    this post, while I am also keen of getting experience.

    My blog post :: wayne dalton garage door opener

  39. What’s Happening i am new to this, I stumbled upon this I
    have found It positively helpful and it has helped me out loads.
    I’m hoping to give a contribution & help different users like its
    aided me. Good job.

    my web site :: replace garage door opener

  40. excellent submit, very informative. I wonder why the opposite specialists of
    this sector don’t understand this. You must continue your writing.
    I’m sure, you’ve a huge readers’ base already!

    Here is my blog post; garage door repair

  41. Great post. I was checking continuously this blog and I am impressed!
    Extremely helpful information specifically the last part :
    ) I care for such info much. I was seeking this particular information for a very long time.
    Thank you and good luck.

  42. I pay a visit day-to-day a few web sites and information sites to
    read articles, except this blog provides quality based content.

    Feel free to surf to my weblog … genie intellicode garage door opener

  43. Hello everybody, here every one is sharing these kinds of familiarity, therefore it’s fastidious to read this website, and I used to pay a visit this website everyday.

    Look at my web blog :: garage door repair

  44. Wow that was strange. I just wrote an incredibly long comment but after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over again. Anyways, just wanted
    to say great blog!

    Check out my page … wireless garage door opener

  45. I do accept as true with all of the ideas you’ve presented in your post.

    They are really convincing and will certainly work.
    Still, the posts are very brief for beginners.
    May you please extend them a bit from subsequent time? Thank you for the post.

    Feel free to visit my web page: linear garage door opener

  46. Heya i’m for the first time here. I found this board and I
    find It really useful & it helped me out much. I hope
    to give something back and aid others like you aided me.

    my website – linear remote garage door opener

  47. I think the admin of this site is actually working hard for his web page, since here every
    stuff is quality based information.

    My web site – chamberlain garage door opener troubleshooting

  48. Link exchange is nothing else however it is simply placing the other person’s website link on your page at suitable
    place and other person will also do similar in favor
    of you.

    Here is my web blog – stanley garage door opener

  49. Hey there! This is my first visit to your blog! We are
    a group of volunteers and starting a new initiative in a community in the
    same niche. Your blog provided us beneficial information to work on. You have done a wonderful job!

    Visit my web page … garage door repair

  50. Magnificent beat ! I wish to apprentice even as you amend your site,
    how could i subscribe for a weblog web site? The account helped me a appropriate deal.
    I were a little bit acquainted of this your broadcast
    provided bright transparent concept

    My page … how to fix garage door opener

  51. Appreciate this post. Will try it out.

    Feel free to visit my page garage door repair

  52. That is a great tip particularly to those new to the blogosphere.
    Simple but very accurate information… Thanks for sharing this one.
    A must read article!

    Visit my homepage … stanley garage door opener remote

  53. You could certainly see your skills in the work you write.
    The sector hopes for more passionate writers like you who
    aren’t afraid to mention how they believe.
    At all times follow your heart.

    Here is my homepage … garage door repair

  54. I’m truly enjoying the design and layout of your website.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create
    your theme? Outstanding work!

    Feel free to visit my weblog outflank dui attorney in orange county

  55. I’ve been surfing on-line more than 3 hours lately, but I by no means
    discovered any attention-grabbing article like yours. It is lovely worth enough for
    me. Personally, if all web owners and bloggers made just right content as you did, the net shall be
    much more helpful than ever before.

    Here is my blog post :: Pest Management Winnipeg MB

  56. Hey there! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?

    Look at my blog post … liftmaster garage door opener manual

  57. This is really fascinating, You’re an excessively skilled blogger.

    I’ve joined your rss feed and look ahead to in quest of extra of your excellent
    post. Also, I’ve shared your site in my social networks

    Here is my page :: Safe Pest Control Halifax NS

  58. hello there and thank you for your information – I’ve
    certainly picked up something new from right here.
    I did however expertise several technical issues using this web site,
    as I experienced to reload the site many times previous to I could
    get it to load correctly. I had been wondering if your web hosting is OK?
    Not that I’m complaining, but slow loading instances times will
    often affect your placement in google and could damage
    your high quality score if ads and marketing with Adwords.
    Well I’m adding this RSS to my e-mail and could look out for a lot more of your respective fascinating
    content. Make sure you update this again soon.

  59. This info is invaluable. Where can I find out more?

    Check out my page … hosted phone system New York City

  60. Alberto says:

    When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several
    emails with the same comment. Is there any way you can remove
    people from that service? Thank you!

  61. Howdy I am so excited I found your website, I really found you by accident, while I was browsing
    on Aol for something else, Nonetheless I am here now
    and would just like to say thanks for a fantastic post and a all round
    exciting blog (I also love the theme/design), I don’t have time to browse it
    all at the moment but I have bookmarked it
    and also added in your RSS feeds, so when I have time I will be back to read a
    lot more, Please do keep up the great job.

    Feel free to visit my webpage – Bed Bugs Pest Control Courtenay

  62. Quality articles is the key to invite the viewers to pay a visit the web page,
    that’s what this web site is providing.

    Feel free to surf to my webpage: Bed Bugs Exterminators Victoria

  63. title says:

    I read this article completely about the resemblance of
    latest and previous technologies, it’s remarkable article.

    my web-site … title

  64. I’m gone to convey my little brother, that he should also visit this web
    site on regular basis to take updated from most up-to-date news update.

  65. Sandy says:

    hello there and thank you for your information – I’ve definitely picked up anything
    new from right here. I did however expertise some technical issues
    using this website, since I experienced to reload the website
    many times previous to I could get it to load correctly.
    I had been wondering if your web host is OK?
    Not that I’m complaining, but slow loading instances times will very
    frequently affect your placement in google and can damage your high
    quality score if advertising and marketing with Adwords.

    Well I’m adding this RSS to my email and can look out for much more of your respective interesting content.

    Ensure that you update this again very soon.

  66. Bernard says:

    Good replies in return of this query with genuine arguments
    and telling all about that.

    Take a look at my homepage – vegasodj.soup.io (Bernard)

  67. Asking questions are actually good thing if you are not understanding anything entirely, but this paragraph provides good understanding even.

  68. Shikha Jha says:

    Hi,
    Thanks for the code. I need some help, i want to ask how to spread out the tabs to take the width of whole screen.Please help me.What kind of code i need to add in it. Please help me. Please reply as early as possible . Thank you.

  69. What i do not realize is actually how you are not really much more well-preferred than you may be right now.
    You’re very intelligent. You recognize therefore significantly
    in relation to this topic, made me for my part believe it from
    so many varied angles. Its like women and men aren’t interested until it’s one thing to do with Woman gaga!

    Your personal stuffs outstanding. At all times take care of
    it up!

    Feel free to visit my web-site: behind the teeth braces Elk Grove

  70. Hello, every time i used to check blog posts here in the early hours in the daylight, because i enjoy to learn more and more.

    My web-site – dental implants cost Elk Grove

  71. You really make it seem so easy with your presentation but I find this
    matter to be actually something which I think I would never understand.
    It seems too complex and extremely broad for me.
    I’m looking forward for your next post, I’ll try to get the hang of it!

    Look into my web-site Raccoon Removal Barrie

  72. Neville says:

    What a data of un-ambiguity and preserveness of precious
    knowledge concerning unpredicted feelings.

    Feel free too surf to my homepage: Android Apps PC [Neville]

  73. Sandy says:

    Excellent beat ! I would like to apprentice while you amend your web site,
    how could i subscribe for a blog web site (Sandy)?

    The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea

  74. make money says:

    Undeniably imagine that which you stated. Your favorite reason appeared to be on the web the simplest
    thing to take note of. I say to you, I certainly get annoyed while people think about worries that they just do not recognize
    about. You controlled to hit the nail upon the top as smartly as outlined out
    the entire thing with no need side effect , folks
    could take a signal. Will probably be again to get more.
    Thanks

    Review my blog post … make money

  75. Awesome website you have here but I was wondering if you knew of any message boards that
    cover the same topics talked about in this article?
    I’d really love to be a part of community where
    I can get suggestions from other knowledgeable individuals that share the same
    interest. If you have any suggestions, please let me know.
    Many thanks!

    my web blog – 24 hour heating and cooling Dothan AL

  76. I think what you wrote was very logical.
    But, think on this, suppose you composed a catchier post title?
    I mean, I don’t wish to tell you how to run your website, but what if you added a post title that grabbed people’s
    attention? I mean Android Tabs with Fragments – Android Magic is kinda vanilla.
    You could peek at Yahoo’s home page and note how they create news headlines to get
    viewers interested. You might try adding a video or a pic or
    two to get readers interested about what you’ve written. Just my opinion, it might make your website a little bit
    more interesting.

    My blog post garage door torsion spring repair Minneapolis MN

  77. You really make it seem so easy with your presentation but I find this matter to be really something which I think I would never understand.
    It seems too complex and very broad for me. I’m looking forward for your next post,
    I’ll try to get the hang of it!

    My site – palm tree removal Birmingham AL

  78. Lelia says:

    The motor is responsible for producing quiet operation while
    driving the blades for air movement. Sometimes there are
    many hidden costs with electrical work, and it is
    easy to get taken for a ride. When picking out the fan, you have to be
    quite watchful.

  79. We stumbled over here coming from a different web page and thought I might check things out.
    I like what I see so now i am following you. Look forward to
    looking at your web page again.

  80. Victorina says:

    Snakes symbolize the eternal revolution of the ages and the succession, dissolution and regeneration of humanity.
    He had the guardsman’s crossbow to his shoulder, aiming a newly loaded bolt across the room.
    Should you’re feeling like you focused your enemy spot on in a shot but still missed, check what arms you are using.

  81. Thanks designed for sharing such a pleasant idea, post is pleasant, thats why i have read it fully

  82. Louisa says:

    I agree with you on many of your original ideas here. You’ve done a great job of
    making this very interesting and clear. Thank you.

    Feel free to visit my web-site

  83. wasim says:

    Confused with the code. you have explained well.
    And how you have used those red and green color for rows ?
    I like the style …

  84. Excellent post. I certainly love this website. Keep writing!

  85. best hack says:

    Everyone loves what you guys are usually up too. This kind of clever work and
    exposure! Keep up the awesome works guys I’ve you guys to my
    own blogroll.

  86. First off I want to say awesome blog! I had a quick question that I’d like
    to ask if you don’t mind. I was interested to find out how you center yourself and clear
    your head before writing. I’ve had trouble clearing my mind in getting my thoughts
    out there. I truly do enjoy writing but it just seems like the first 10
    to 15 minutes are generally wasted just trying to figure out how to begin.
    Any ideas or hints? Thank you!

  87. Willem Ghijsen says:

    Nevermind. I played around with it, and the strings are called from strings.xml. I originally thought it was in the java code:
    public static final String TAB_WORDS = “words”;
    public static final String TAB_NUMBERS = “numbers”;
    but that was incorrect

  88. Willem Ghijsen says:

    I was going through the code, and added an extra tab to experiment. This was successful, however, I cannot seem to find out how/why the tabs start with a capital letter, since the strings passed in are all lowercase. Does anyone know why this happens?

  89. thx for this tutorial !but i have a question !!
    how to hide the titles of the tabs !
    need your help !

  90. These are in fact enormous ideas in on the topic of blogging.

    You have touched some nice factors here. Any way keep up wrinting.

  91. k40s says:

    Thanks a lot for this

  92. John says:

    Very useful. Thanks

  93. bahaha says:

    Can you please post the entire source code? Where is r.id.bar defined, new to android here.

  94. vkhooda says:

    Well Blog post…By the developer for the developers….:)
    Thanks for sharing good tutorial about tab in fragments.

  95. Tom says:

    Brilliant! I was looking for use of custom tabs with fragments because I wanted to use the new Navigation Drawer! Only tutorial I can find that does what I want and I’ve been looking for 3 days! A+++!

  96. Zeus says:

    Can u pls suggest as to how can i add an onclick listener to one of the tab to open a new activity or fragment inside the same tab

  97. Zeus says:

    What if i wanted to start a child activity form one of the tabs then would the tabs still be maintained on that child

    activity as well

  98. Ankit Rohilla says:

    thank you for great tutorial
    Its working

  99. Babar says:

    Hi How can i have tabs at bottom??

  100. Shakir Orakzai says:

    wonderfull very nice

  101. arw357 says:

    Thx . usefull indeed !

  102. rashid says:

    How do i implement this using ListView instead of Creating a list of LinearLayouts? Pls help.

  103. mesi says:

    what is R.id.bar ? pls mention

  104. Jim_Welke says:

    Right on, Evalina! Great code sample; it clarified a lot things I (an Android newbie) was struggling with. Specifically, how to structure the .xml files so that configuration info and selectors work right. I appreciate the clarity in your comments, too. Thanks. Peace.

  105. Authman Apatira says:

    This project (FragmentTabs) crashes when you rotate the device 4x.

  106. dereky says:

    it really helps me a lot,thanks very much

  107. Dusan says:

    OMFG! Does anybody know why i cant set weight atribut on root LinearLayout in tabs.xml. I tryed a lot of thing, but it wont work… I want tabs to spread out to take whole screen…

  108. Dim says:

    Is it simple enough to add each fragment to the backstack such that hitting the back button returns to the previous tab?

  109. nate says:

    If you wanted to make one of the fragments a mapview how would you go about do that?

  110. Everton Barros says:

    Very nice post, I needed to do something similar, only in my case I needed to put tabs in a popup, after picking up a bit, I managed to reach the final solution. Thank you!

  111. rathael says:

    I think you must change “getListView().setAdapter(mAdapter);” by “setListAdapter(mAdapter);”.

  112. jin says:

    Hi, This tutorial really helped me a lot. I want to make a third tab, but unable to code it. Pl help for the same.

  113. CH4:D says:

    Line 106 is wrong. It should just simply be
    if (mPosition < mTotal).

    As it stands, the last element in the array won't show up if you add the "- 1" because it stops one item behind.

  114. Alex says:

    this is crashing on second orientation change

  115. binhbt says:

    Oh man. Thanks a lot. nice example :X:X:X:X:X:X:X:X::-*

  116. zx81 says:

    Hi, Thanx for nice example, saves lot of learning time.

    BTW, what is R.layout.tab in newTab() and how can I create a proper XML for that element?

  117. seetha says:

    you are superb dear….

  118. Filip Bulovic says:

    Very nice example, thanks.

  119. mith says:

    Hi. Thanks for the wonderful code and tutorial. I have a question though. How could I make the tabs scrollable as in if I add many tabs , how to make it scrollable horizontally ?
    Thanks

    • mith says:

      A quick google search helped me.. This is how I did

      Hope this helps somebody.
      Thanks

    • evelyne24 says:

      Hey, thanks for the comment. My code has become a bit obsolete because there are other people out there creating compatibility libraries to support all kinds of ICS features, including tabs, tabs + swipe, etc. Best look for Jake Wharton’s libraries (he’s the author of ActionBarSherlock). Check out this library: https://github.com/JakeWharton/Android-ViewPagerIndicator/ it probably has everything you want.

      • Thomas Markle says:

        You should add an update at the top of the post, I just found the ABSherlock library and it looks like it’s a great time saver.

  120. nicolas raby says:

    Hi, android.support.v4.app.FragmentActivity , does I mean the code requires Android v4 at least ?

  121. kyk says:

    Thanks for posting a working project!

  122. Gladiatornoida says:

    I found it in your code. Thanks!

  123. Gladiatornoida says:

    private TabSpec newTab(String tag, int labelId, int tabContentId) {
    Log.d(TAG, “buildTab(): tag=” + tag);

    View indicator = LayoutInflater.from(getActivity()).inflate(
    R.id.tab,
    (ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
    ((TextView) indicator.findViewById(R.id.text)).setText(labelId);

    TabSpec tabSpec = mTabHost.newTabSpec(tag);
    tabSpec.setIndicator(indicator);
    tabSpec.setContent(tabContentId);
    return tabSpec;
    }

    Can you please give explanation for R.id.tab & indicator.findViewById(R.id.text). From where these ids come?

    • Kyle Beckman says:

      I have the same question…. any help?

      • Nelson says:

        I’m not sure about R.id.tab, but I think you actually mean android.R.id.tabs, but R.id.text is just the id of a TextView defined in the list_item.xml file. She’s not talking about it in the text, but if you download the tar file with the whole project there you can see that file, which is actually the layout for every single row displayed in the listview.

        • Nico Sordoni says:

          R.id.tab doesn’t appear anywhere, but instead appear R.layout.tab, that is the layout used as “background” for the indicators of the tabs. R.id.text is a TextView inside this layout, used to contain the text of the tab’s indicator.

  124. Tom Karni says:

    This is a greate tutorial, helped me a lot.

  125. samcool says:

    Is there an article only for fragments ? I searched around for lot of tutorials and tried implementing by following them but couldn’t get it working. I am looking for fragment implementation which will work on all the android versions. That will be really helpful. Thank you in advance.

  126. Zerotvt says:

    Thanks

  127. Dada Venki says:

    hi i have read your tutorial its nice but i have a doubt if in any tab if i want to move another screen (same tab) like clicking any of the rows in listview how it can be done any suggestion will be a great help

  128. ye009 says:

    Can you post some code for listFragment with which used customlistAdapter in setAdapter and listfragment loads data from asychTaskLoader, I am having problem with how to refresh the listfragment when data is loaded from asynchTaskLoader. Please help

  129. Vinesh Gaadhe says:

    Ohhh man u rocks… I was looking for this from last 24 hours…thanks a lot man

  130. Cloud Jacker says:

    Thanks! I dont understand what your activity is doing though, why do the individual tabs load the words and numbers so slowly? Is that a fragment feature?

    I need to use tabs to load full layouts. Ie tab 1 loads an activity and tab 2 loads a separate activity! But TabActivity and that entire methodology is deprecated, yet this fragment “replacement” isn’t very intuitive for froyo+

    • Evelina Vrabie says:

      Have you read the code? The words are loaded slowly because I wanted to simulate an operation that takes time, like a network call. If you actually read the code you’ll see there’s a Thread.sleep() that does the trick (there’s a comment that says that as well).

      About the methodology, if you think it’s deprecated then use something else that you see fit. If you find a better way, please share so we can all learn

  131. Abe Froman says:

    When I try running the code you provided I just get a loading icon that never goes away. The done loading string appears in my LogCat but nothing is appearing on the screen. If you have any ideas what I may have done wrong please let me know.

    • Brill Pappin says:

      Run it through the debugger, that’s that it’s for.
      I had to modify it as well for my project, but it works just fine.

      • Tom Karni says:

        I had the same problem when I used it in my project but not when I ran this package. Brill, how did you solve it?

    • U Sargin says:

      i have used android-support-v13 no v4 and i have same problem

      • Tom Karni says:

        I finally solved it with:
        @Override
        public void onLoadFinished(Loader loader, Void result) {
        //update adapter

        setListShown(true);
        }

        • CH4:D says:

          God, this really solved my issue as well! I’ve been up all night trying to customize this tutorial to suit my needs but even simple label and id adjustments screw this app up.

          I don’t know if this is an android or eclipse bug but i tried tracking the changes little by little and rerunning at each change.

          It appears that if you add one extra tab to the tabs_fragment.xml the whole application gets foobar’d. However, this may not be the exact cause but probably a consequence because the issue is intermittent.

          Sometimes the loading screen shows up even if you undo the changes and uninstall the app. Sometimes it just corrects itself after a few runs.

        • rathael says:

          Try to change “getListView().setAdapter(mAdapter);” by “setListAdapter(mAdapter);”.

  132. Brill Pappin says:

    Here is anther tip. The tab in your example are left aligned.
    if you add the android:layout_weight=”1″ attribute to the root LinierLayout of tabs.xml they will spread out to take up the whole width of the screen.

    Long labels will still cause some tabs to be longer than others, but that would be an issue no matter what you did.

    It was also easy to add an image to the tabs.xml so that you get a more “iphone” like effect.

  133. Brill Pappin says:

    Best example of Tabs with Fragments i’ve seen yet. A simple as can be and the code is clean and obvious.

  134. tabbykitten says:

    Thanks for tips
    tab_1, tab_2 is overhead for tabhost_fragment.xml is overhead, you can use android.R.id.tabcontent directly

  135. Vinh Bui says:

    Thanks a lot, it’s really useful to me.

  136. peng wang says:

    thanks,it is help me .

  137. Evelina Vrabie says:

    Glad to help

  138. Jalota_arun says:

    Thnx alot…this exact i have been lokking for last 3 days…!!gr8 post thnk u!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>