Reputation: 611
I have a requirement as shown in this image.
I have 2 show 2 object data on single row. Normally we show these information as one object in one row. How could we achieve it.
Upvotes: 0
Views: 122
Reputation:
You need ListView xml, ListItem xml, ListItem class (object), ArrayAdaper class
Set a row view and items in that view in ListItem xml. Create ListItem class (object) with variables (Such as String, int) you needed. Bind the view and item in ArrayAdapter class.
Upvotes: 0
Reputation: 2211
You can achieve it customizing getView() method in listview adapter. what getView() method do?
getView() normally generates view for each row in a general sense.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//inside this we populate data using position value
}
Here you need to show two object (sequence or random) data in a single row. You need to use another int variable to keep track about object size.
initialize it on top, int i = 0;
inside getView() you need to do something extra because you need to populate 2 object data on a single getView() method call.
****Populate data inside above if condition.
*Custom layout GridView example
Upvotes: 1