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
Asked
Active
Viewed 2,500 times
0
-
1http://stackoverflow.com/questions/17370525/listview-adapter-with-arbitrary-number-of-row-types-dont-know-the-number-of-di/17370772#17370772. check this. – Raghunandan Jul 06 '13 at 13:57
2 Answers
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;
}

Blundell
- 75,855
- 30
- 208
- 233
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.

kaushal trivedi
- 3,405
- 3
- 29
- 47