Reputation: 9646
I am using a ListView
and a custom adapter (FooAdapter
)
the FooAdapter
sets the list view in the constructor like this:
public FooAdapter(Context context, List<Foo> list) {
super(context, R.layout.list_item_foo, list);
this.list = list;
this.inflater = LayoutInflater.from(context);
}
All that is working fine
Question
For the first row of the ListView
I want to change the design of the row. Is that possible? Here is a mockup of what I'm envisioning.
Upvotes: 0
Views: 40
Reputation: 7494
Yes you can modify just the view for the first element by overriding the method getView from the BaseAdapter class as follows:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (position == 1) {
// do some view processing
return View;
} else {
// do some other view processing
return thisView;
}
Upvotes: 0
Reputation: 1233
You can add a header to the ListView like this:
View header = getLayoutInflater().inflate(R.layout.header, null);
listView.addHeaderView(header);
The header will scroll with the content.
Upvotes: 1