How can I modify the text color of the selected item on a Spinner in an Android Honeycomb application?
EDIT: I have a Spinner layout which i\'m inflating. Is it possible
I used this code for ListView adaper:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView;
EntSaleDocumentDetails entSaleDocumentDetails = getItem(position);
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflator.inflate(R.layout.myLayout,
null);
} else {
rowView = (View) convertView;
}
TextView myTv= (TextView) rowView
.findViewById(R.id.tvCode);
myTv.setTextSize(16);
//....
// set selected item
LinearLayout ActiveItem = (LinearLayout) rowView;
if (position == selectedItem)
{
ActiveItem
.setBackgroundResource(R.drawable.background_dark_blue);
}
else
{
ActiveItem
.setBackgroundResource(R.drawable.border02);
}
//....
}
public void setSelectedItem(int position) {
selectedItem = position;
}
your custom layout:
and in activity:
@Override
protected void onListItemClick(ListView parent, View view, int position,
long id) {
super.onListItemClick(parent, view, position, id);
adapter.setSelectedItem(position);
myListView.invalidateViews();
}