I have a Spinner
and a SimpleCursorAdapter
.
For odd/even rows on this spinner i set some color, background, font size.
Also in my cursor there is a empty value. For this i want to display just a 5 pixels height line. I do not know how to do this.
Like a example i want something like this
Row1
Row2
Row3
----
Row4
Row5
Here is my attempt code
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
if (position % 2 == 0) {
view.setBackgroundResource(R.layout.dropdown_selector_odd);
} else {
view.setBackgroundResource(R.layout.dropdown_selector_even);
}
TextView text = (TextView) view.findViewById(R.id.spinner_item_name);
String driverSpinnerRow = text.getText().toString();
if (driverSpinnerRow.trim().length() == 0) {
// Here must add this line
text.setHeight(5);
}
return view;
}
Can someone help me?
This is what you need. Instead of images, suppose that are lines, and instead of setting the source of the image, set visible/invisible to the lines.
Here is a similar tutorial about how to create a custom layout for the rows. Add the 5 pixels height line to the row layout and set it to be invisible. Then in the adapter set it to visible when needed. This ListView tutorial may help to create a custom adapter.