Can I have a scrollable list inside a tab?

  • Replies:5
  • OpenNot stickiedUnanswered
  • Forum posts: 6

Nov 20, 2014, 8:58:15 PM via Website

I can't find any examples of this anywhere, every time I try and put a listview inside a fragment tab view, it will only show one of the views. I can't get 2 to work together. How is this done? I searched all over the internet for code examples I can download and play with but found nothing. Please show me how this is done. Thanks.

  • Forum posts: 118

Nov 20, 2014, 9:05:50 PM via App

Do you use a layoutinflater to inflate the layout of your listview into one of the tabs' fragment? Could you perhaps show us your fragment java file where you include the tabs.

  • Forum posts: 6

Nov 21, 2014, 3:09:13 AM via Website

        // Initilization
    viewPager = (ViewPager) findViewById(;
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());


    // Adding Tabs
    for (String tab_name : tabs) {

Is that the part you wanted? I think this is the package I downloaded here:

I like the idea of being able to swipe between tabs but it's not mandatory. And the scrolling list only needs to be half the width of the tab if that helps.

  • Forum posts: 118

Nov 21, 2014, 10:26:52 AM via Website

That's indeed the right package. I recommend you to start a new project and use only that code. Modify the mainactivity into a fragment instead of fragmentactivity and try to embed it into an activity with the getSupportFragmentManager in the new activity. I could write down the code myself for you if you wish however you would learn nothing from that. Don't worry about the result, we will definitely get there as I have my own project with similar own made code so I already have the solution, unless you say: "Hey don't waste my time, give me the code"! :)

Take a look at this, it would help you get on the right path to your solution:

— modified on Nov 21, 2014, 10:32:56 AM

  • Forum posts: 6

Nov 30, 2014, 5:09:34 AM via Website

Thanks, I think I got it! I found this package online and it does everything I need it to do......except one thing.

It does the custom list views on fragment tabs but I need to load the list from a HTTP request to my web server. I know how to do the HTTP request but I'm not sure how to update the list OnPostExecute. I'm downloading all kinds of packages and trying to copy the code over but those all seem to extend Activity when I'm extending FragmentTab. Any ideas/

  • Forum posts: 6

Dec 3, 2014, 12:52:17 AM via Website

Anyone have any hints? I just want to get a single response from a server, I can parse the JSON myself later.

Recommended by NextPit