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

  • SEARCH
  • Home
  • 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 7176731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:34:07+00:00 2026-05-28T16:34:07+00:00

I have a Custom ListView that contains a vertical LinearLayout of horizontal LinearLayouts for

  • 0

I have a Custom ListView that contains a vertical LinearLayout of horizontal LinearLayouts for each list item. The horizontal LinearLayout contains 4 buttons. The problem is that only 1 of the 4 buttons is showing when I display the ListView.

I have my empty vertical LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="6dip"
    android:background="@color/all_white"
    android:orientation="vertical"
    android:id="@+id/linear_layout"
    />

My horizontal LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dip"
android:background="@color/all_white">
<Button
    android:id="@+id/ws_1"
    android:layout_width="175dip"
    android:layout_height="wrap_content"
    android:layout_marginRight="8dip"
    android:paddingTop="10dip"  
    android:paddingBottom="10dip" 
    />
<Button
    android:id="@+id/ws_2"
    android:layout_width="175dip"
    android:layout_height="wrap_content"
    android:layout_marginRight="8dip"
    android:paddingTop="10dip"  
    android:paddingBottom="10dip" 
    />
<Button
    android:id="@+id/ws_3"
    android:layout_width="175dip"
    android:layout_height="wrap_content"
    android:layout_marginRight="8dip"
    android:paddingTop="10dip"  
    android:paddingBottom="10dip" 
    />
<Button
    android:id="@+id/ws_4"
    android:layout_width="175dip"
    android:layout_height="wrap_content"
    android:layout_marginRight="8dip"
    android:paddingTop="10dip"  
    android:paddingBottom="10dip" 
    />    
</LinearLayout>

and my getView of the custom BaseAdapter class:

public View getView(int position, View convertView, ViewGroup parent) {
    ViewGroup viewGroup = null;
    int numRows = 0;

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) _activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        viewGroup = (ViewGroup) inflater.inflate(R.layout.linear_layout, null);
    } else {
        viewGroup = (ViewGroup) convertView;
        numRows = viewGroup.getChildCount();
    }
    _keys = (String[]) _workspacesMap.keySet().toArray(new String[_workspacesMap.size()]);
    List<WorkspaceInfo> workspaces = new ArrayList<WorkspaceInfo>();
    try {
        if (_keys[position] != null) {
            workspaces = _workspacesMap.get(_keys[position]);
            Collections.sort(workspaces, new InfoNameComparator());
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        //
    }

    int totalRows = 0;
    if (workspaces.size() > 0) {
        totalRows = workspaces.size() / 4 + 1;
        if (totalRows % 4 != 0) {
            totalRows++;
        }
    }

    if (numRows < totalRows) {
        for (int i = numRows; i < totalRows; i++) {
            View view;
            LayoutInflater inflater = (LayoutInflater) _activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = (View) inflater.inflate(R.layout.list_row_multi_ws, null);
            viewGroup.addView(view, i);
        }
    } else if (numRows > totalRows) {
        for (int i = totalRows; i >= numRows; i--) {
            viewGroup.removeViewAt(totalRows);
        }
    }

    Iterator<WorkspaceInfo> iterator = workspaces.iterator();
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        ViewGroup temp = (ViewGroup) viewGroup.getChildAt(i);
        for (int j = 0; j < temp.getChildCount(); j++) {
            Button button = (Button) temp.getChildAt(j);
            if (iterator.hasNext()) {
                String buttonText = iterator.next().getTitle();
                button.setText(buttonText);
            } else {
                button.setVisibility(View.GONE);
            }
        }
    }
    return viewGroup;
}
  • 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-05-28T16:34:08+00:00Added an answer on May 28, 2026 at 4:34 pm

    Try to change your inflate method with this one:

    inflater.inflate(R.layout.linear_layout, parent, false);
    

    It might help.

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

Sidebar

Related Questions

I currently have a custom listview where each item on the list contains two
I have a listview that contains values from webservice.Each page contains only 10 listitems
I have a ListView with few elements, each item contains two buttons with a
We have created custom listview by using the Base adapter. List view contains Text
I have a ListView that contains a list of TextViews, and in my onItemClick()
I have list view with custom row layout (list_row.xml) that contains CheckBox element: <TableLayout
I have a custom baseadapter that i use to populate a listview. each row
I have a custom listview row that contains a number of textView components. Instead
I have created a custom listview that is populated using a row.xml file. Each
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter

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.