Question

I'm trying to make (for learning purposes) my own implementation of a simple AdapterView. Now I have a question: How to add a headerView in my custom adapterView like addHeaderView in listView?

I have realized the waterfall part by using adapterView, but the header I have has special demands: it can slide horizontally and the whole view as below can slide up and down. I never wrote waterfall as below, but write single lines in listView, I can use addHeaderview method to add a viewpager in listView to meet the demands, but I can't understand how to do it in adapterView.

Because I'm a freshman, I can't upload pictures, but you can look at pinterest. I just want to replace the header part aboved waterfall part with a viewpager.

Was it helpful?

Solution

Not sure I understand you are looking for.

ListView is a control have a part that is the header, wich you can customize setting a custom view with addHeaderViewMethod.

AdapterView defines a control that is used to display data with a custom style or information distribution (in a ListActivity for example)

I guess your header is the activity header. I hope to help you.

UPDATED:

Ok, you must follow these steps:

1 - You are extending AdapterView. Define a method class like AddHeaderView (like ListView) for adding required header views

2 - Create a ViewPager wrapper. This class must wrap ViewPager control that you are using with AdapterView (required for horizontal slide)

3 - On setAdapter method implementation, you must check if header views was added, then the adapter passed to this method must be wrapped by your ViewPager wrapper.

I highly recomend you that take a look into source code from ListView and HeaderViewListAdapter. This is the way to get what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top