I want to create a ListView with alternating row layouts.
Row 1 - Layout A
Row 2 - Layout B
Row 3 - Layout A etc.
Is it necessary to create a Custom Adapter for that or is it by default possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No you can’t do this without Adapter, but look at
getViewTypeCount()andgetItemViewType(postion)of the BaseAdapter class, as they will support you.First let your Adapter know how much different types your rows have; in your case they are 2 (Layout A, and Layout B).
The second method returns the type for the given position. In your case it could be something easy like the following code.
See: http://android.amberfog.com/?p=296 for more information.