Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:54:32+00:00 2026-06-14T11:54:32+00:00

I want to show several ListView views, each with its corresponding title in a

  • 0

I want to show several ListView views, each with its corresponding title in a LinearLayout.

I have a LinearLayout, I inflate a view to fill the title and ListView and add that view to the LinearLayout in a loop, but only one title and list appears (the first one).

I want the the view containing the title and the list view, to appear as many times as the for loop repeats.

Let me show you the code:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

//fragment_history: a layout with a LinearLayout inside called "main"

      View fragmentHistory = inflater.inflate(R.layout.fragment_history, container, false);

//I want to show a date, and all the transactions accomplished that date. With this two arrays, I pretend to loop by day, show the date as title and show the transactions of that day in the listview.

        allExpenses = dataExpenses.getAllExpenses();
        allDatesExpenses = dataExpenses.getAllDates();

// The LinearLayout inside the fragmentHistory layout 

        LinearLayout mainLayout = (LinearLayout) fragmentHistory.findViewById(R.id.main);       
        LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

// I made a for loop, and I have two different dates. Two transactions in the first date, and one in the second day. But only the two transactions are been shown.

        for(int x = 0, y = allDatesExpenses.size(); x < y; x++){

            View view = layoutInflater.inflate(R.layout.layout_title, null);        

            Expense expense = allDatesExpenses.get(x);

            TextView text = Font.useHandelGotic(this.context, (TextView) view.findViewById(R.id.textViewTitleDate)) ;
    text.setText(expense.getDateExpense());  

            ListView listview = (ListView) view.findViewById(android.R.id.list);

            ArrayList<Expense> expensesByDate = (ArrayList<Expense>) dataExpenses.getExpensesByDate(expense.getDateExpense());
            listview.setDivider(null);
            listview.setAdapter(new AdapterTransaction(this.context, expensesByDate));

            mainLayout.addView(view);

        }       
        return fragmentHistory;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:54:33+00:00Added an answer on June 14, 2026 at 11:54 am

    From the information you’ve given, I would guess that your LinearLayout is set to horizontal (the default), so all of your titles/listviews are actually being added but you can’t see them because they’re off the side. Fix that by adding

    android:orientation="vertical"
    

    to your LinearLayout XML tag.

    If that’s not the problem, then post the pertinent XML layouts please.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have user control, which i render on several views. i want to show
I have several distinct View objects, stored in the views array, that I want
I have data of students from several schools. I want to show a histogram
I want to create a listview where each element has several imageview, but they
I have several <p> elements in my HTML body. I only want to show
I have a navigationControll with several views. Everything works properly. I now want to
I have several SeekBar and onSeekBarProgressStop() , I want to show a Toast message.
What I want to do I have several items in a ListView. When I
I have a several links on the page and I want to show individual
I have several local html files and I want to show them in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.