Reputation: 17289
In my application I can only use the same layout for each listview item in each row. This is not what I want for my application and I would like to have a different layout for each of the listview items.
As an example of what I would like to achieve please see the screenshot below.
Upvotes: 1
Views: 112
Reputation: 6201
You can do it via android Listview BaseAdapter. In BaseAdapter getView method, you can added code like this.
public View getView(final int position, View convertView, ViewGroup parent) {
if(item1 or your condition)
{
convertView=inflater.inflate(R.layout.from_right_row.xml, parent, false);
}else if(item2 or your condition) {
convertView=inflater.inflate(R.layout.from_left_row.xml, parent, false);
}
return convertView;
}
Upvotes: 1