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 4114214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:25:37+00:00 2026-05-20T22:25:37+00:00

I have done my custom ListView, the xml was following: <?xml version=1.0 encoding=utf-8?> <LinearLayout

  • 0

I have done my custom ListView, the xml was following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
  <ListView android:id="@+id/list" android:layout_width="1px" android:layout_height="1px" android:layout_weight="1"></ListView>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent">
      <ImageView android:id="@+id/img" android:layout_width="26px" android:layout_height="30px" />
      <TextView android:id="@+id/title" android:layout_width="248dp" android:layout_height="wrap_content" android:textStyle="bold" android:paddingLeft="6dp" android:textSize="20sp" />
      <ImageButton android:id="@+id/cat_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:layout_marginRight="2dp" />
      <ImageButton android:id="@+id/act_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" />
  </LinearLayout>
</LinearLayout>

‘
And code is

public class MyListActivity extends ListActivity
{
  protected void onCreate(Bundle savedInstanceState)
  {
    Log.i("MyApp", "ON List create......");
    super.onCreate(savedInstanceState);
    List<BeanObj> list=...//Do something to fill list
    setListAdapter(new MyListViewAdapter(context, R.layout.item_view, list));
  }

  public class MyListViewAdapter extends ArrayAdapter<List<BeanObj>>
  {
    private List<BeanObj> hList=null;
    public MyListViewAdapter(Context context, int textViewResourceId, List hList)
    {
      super(context, textViewResourceId, hList);
      this.hList=hList;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent)
    {
      final BeanObj bean=this.hList.get(position);
      LayoutInflater inflater=getLayoutInflater();
      View row=inflater.inflate(R.layout.item_view, parent, false);
      // Do something to fill ListView
      return row;
    }
  }
}

I did try to add a button on it, but I got each button on each row of list view…

What can I do on xml to add floating button over my custom list view ?
Or, I caeate another xml layout file below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="left|top">
  <Button android:id="@+id/btnLogout" android:layout_width="wrap_content" android:layout_height="40dp" android:text="@string/buttonLogout" />
  <View android:layout_width="75dp" android:layout_height="40dp" />
  <Button android:id="@+id/btnList" android:layout_width="wrap_content" android:layout_height="40dp" android:text="@string/buttonList" />
  <Button android:id="@+id/btnSearch" android:layout_width="wrap_content" android:layout_height="40dp" android:text="@string/buttonSearch" />
</LinearLayout>

How did I to use it via addHeaderView or addFooterView method ?

  • 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-20T22:25:37+00:00Added an answer on May 20, 2026 at 10:25 pm

    You need to add the header and the footer before setting the ListAdapter for the list. From the docs:

    NOTE: Call this before calling
    setAdapter. This is so ListView can
    wrap the supplied cursor with one that
    will also account for header and
    footer views.

    Also inflating your views in the getView method is not the most optimum way. You need to use a static class for storing the reference to the inflated view. Check out this talk to correctly set up the views.

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

Sidebar

Related Questions

I have a custom adapter for ListView and I need to return LinearLayout from
I have the following issue: I have a listview with custom rows, and on
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
In my Android application I have a ListView with 5 elements. I created a
I have done I custom class method for NSString to md5 a NSString. This
Do I need to load my custom ListAdapter in another thread? I have done
So I have a custom ListView object. The list items have two textviews stacked
I need help writing custom functions for my casio fx-9860g I have done this
We are not using GKPeerPicker control. We are implementing custom UI. We have done
I have a custom listview in which I have a Textview and Imageview now

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.