0

I wanted to extend and ArrayAdapter so that the layout of the first row is different to the layout of the remaining items.

Many thanks in advance!

3 Answers 3

1

there is a addHeader for listView. you can use it inflate different view for the first item in the list.

listview.addHeaderView(customView);

you have to inflate your customView before adding it to the listView header.

Sign up to request clarification or add additional context in comments.

1 Comment

I haven't gotten round to this as I've been tackling other parts of the project but I'll be sure to accept this if it works. Thank you!
0

it is simple enough override getView() method of arrayadapter write an if condition for position 0

if (position==0) {
t = (TextView)convertView.findViewById(R.id.text);
t.setVisibility(false);
// etc.

}

or you could add header to your listview listview.addHeaderView(v)

Comments

0

You could have something similar to this

     public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if(position==0){
View row = inflater.inflate(R.layout.layout, parent, false);
}else{
View row = inflater.inflateR.layout.other_layout, parent, false);
}

 ......
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.