0

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.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
JavaFreshman
  • 53
  • 1
  • 1
  • 5

1 Answers1

0

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.

Hybos
  • 156
  • 12
  • I want to write a waterfall view like pinterest feedlist, I know write a view extends adapterView can do it; but I have a special demand: I have add a view ,this view like viewpager , it can horizontal slide. I add use addHeaderView method to add this viewpager in listView earlier,but I don't know how to do this in adapterView!the demo I want to finish, I show you as upper – JavaFreshman Jan 25 '13 at 17:45