El getView que he implementado es el siguiente:
/**
* Make a view to hold each row.
*
* @see android.widget.ListAdapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
public View getView(int position, View convertView, ViewGroup
parent) {
// A ViewHolder keeps references to children views to avoid
unnecessary calls
// to findViewById() on each row.
ViewHolder holder;
// When convertView is not null, we can reuse it directly,
there is no need
// to reinflate it. We only inflate a new View when the
convertView supplied
// by ListView is null.
if (convertView == null) {
convertView =
mInflater.inflate(R.layout.my_normal_spinner_item_style, null);
// Creates a ViewHolder and store references to the
two children views
// we want to bind data to.
holder = new ViewHolder();
holder.text = (TextView)
convertView.findViewById(R.id.textColor);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the
TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
holder.text.setText(arrayColor[position]);
holder.text.setTextColor(0xFF0000);
return convertView;
}
Donde el R.layout.my_normal_spinner_item_style es:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/textColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
y el arrayColor.xml:
<resources>
<string-array name="color" >
<item>Blue</item>
<item>Green</item>
<item>Red</item>
<item>Yellow</item>
<item>Orange</item>
<item>Brown</item>
<item>Purple</item>
<item>Pink</item>
<item>Grey</item>
<item>White</item>
<item>Black</item>
</string-array>
</resources>
El getDropDownView lo he puesto idéntico al getView y ViewHolder:
static class ViewHolder {
TextView text;
}
On Nov 2, 9:33 pm, Estiven Restrepo <
estiven...@gmail.com> wrote:
> Hola!!
>
> Según veo lo estas llamando de forma adecuada, el problema debe estar en la
> clase MyAdapter, si quieres muestranos el código para ayudarte con ello.
>
> Saludos,
> Estiven Restrepohttp://www.androidcolombia.comhttp://
www.mdeplus.com
>
> 2010/11/2 Pao <
olapa...@gmail.com>
>
>
>
> > Buenas,
>
> > Llevo unos días con ello, pero no consigo dar con el problema.
>
> > He creado un nuevo Adapter,MyAdapter que extiende de baseAdapter como
> > en el ejemplo que hay en API Demos para las listas. La diferencia es
> > que en lugar de extender la clase que lo llama de ListActivity
> > exitiende de Activity a secas, al querer usarlo para personalizar un
> > Spinner.
>
> > He sustituido el ArrayAdapter que leia los datos de mi array (en un
> > xml en local) para escribrilos en el Spinner, por myAdapater de la
> > siguiente manera:
>
> > Spinner s3 = (Spinner) findViewById(R.id.spinnerColor);
> > arrayColor = getResources().getStringArray(R.array.color);
>
> > MyAdapter adapter3=new MyAdapter(c,arrayColor);
>
> > // ArrayAdapter adapter3 = ArrayAdapter.createFromResource(
> > // this, (R.array.color),
> > R.layout.my_normal_spinner_item_style);
> > //
>
> > adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
> > > > >>
desarrolladores-a...@googlegroups.com<desarrolladores-androi
d%2Bunsu...@googlegroups.com>
> > <
desarrolladores-android%2Bunsu...@googlegroups.com<desarrolladores-and
roid%252Buns...@googlegroups.com>
> >
desarrolladores-a...@googlegroups.com<desarrolladores-androi
d%2Bunsu...@googlegroups.com>
> > Para tener acceso a más opciones, visita el grupo en
> >
http://groups.google.com/group/desarrolladores-android?hl=es.- Hide quoted text -
>
> - Show quoted text -