Reputation: 64
is it possible to set a relativelayout array as items for spinner?
RelativeLayout[] items = new RelativeLayout[]{dep1.createObj(getContext()), dep2.createObj(getContext())};
ArrayAdapter<RelativeLayout> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, items);
_deposit.setAdapter(adapter);
i'm getting this as an output:
I would like to use the relativelayout because the object i want to display contains two strings to be displayed with left and right alignment
Upvotes: 0
Views: 99
Reputation: 4442
No, you can only populate String
in unmodified ArrayAdapter
with default layout(which is pretty boring).
If you want to change the default behavior, like change the layout like you mentioned above, you have to extend an adapter like ArrayAdapter
.
Here is an example of custom adapter
Upvotes: 1