0

I know how to create a custom listview in android. But like in iPhone application development we can set multiple different uicellview styles for each row. Is it possible in android if yes how can we achive this. Your help will be appreciated

1

2 Answers 2

1

use the position of the item in your getView method.

Pseudo:

public View getView(int position, View recycledView, ViewGroup group) {
   View view;
   if(position == 1){
        view = View.inflate(context, R.layout.view1, null);
   } else {
        view = View.inflate(context, R.layout.view2, null);
   }

  // populate the view

return view;
}

Reference: http://developer.android.com/reference/android/widget/Adapter.html#getView(int, android.view.View, android.view.ViewGroup)

http://developer.android.com/reference/android/view/View.html#inflate(android.content.Context, int, android.view.ViewGroup)

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

Comments

0

You can achieve this by inflating multiple xml layout files and return them based on condition .

For example inside your getview() method of adapter

you can do like this

for condition 1 

inflate layout 1 and return view

for condition 2 

inflate layout 2 and return view.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.