Hi everyone i am trying to make a static header in my ListView linked to a CustomBaseAdapter.
I want to achieve that the header remains on top and does not scroll with the ListView.
The other items, should dissapear under the header if i scroll the list.
The header is being set via a xml file (lvheader) i made.
The header is displaying correctly above my ListView but it is not static and scrolls with the ListView.
Can somebody please help me with this?
Thx in advance
I already searched stackoverflow to get some ideas, here is the result.
Add the header into the ListView in my Main.xml:
ListView kp = (ListView)findViewById(R.id.listvw);
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.lvheader, kp, false);
kp.addHeaderView(header, null, false);
ArrayList<SearchResults> searchResults = GetSearchResults();
kp.setAdapter(new MyCustomBaseAdapter(AndroidLogin.this, searchResults, icons));
...
}
Afaik, all that addHeaderView() does is add the item at the top of the list, but it is not supposed to make it “fixed” (unscrollable). If you want to have an item that’s fixed, it sounds like you should have two views arranged in a vertical LinearLayout: the top one is the fixed part, and the bottom one is a ListView.