Sylvain-a Posted February 5, 2012 Share Posted February 5, 2012 Bonjour, Alors voila, je tente de faire un spinner personnalisé comprenant 2 TextView. L'un des TextView a un background de couleur (qui change à chaque ligne) généré à partir d'un drawable personnalisé et un texte blanc. Le second TextView n'a rien de particulier. Le problème, c'est que le premier TextView s'affiche en noir, sans texte lorsque l'on déroule le spinner (L'affichage est normal sinon). Vous avez une image en pj. J'ai créé un adapter personnalisé qui s'occupe du convertview Voici le code de la ligne du spinner : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/line_row_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/white" android:background="@drawable/line_number" android:gravity="center" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="1dp" android:paddingBottom="1dp"/> <TextView android:id="@+id/line_row_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" /> </LinearLayout> public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null){ convertView=inflater.inflate(R.layout.lines_list_item, null, true); TextView nText=(TextView)convertView.findViewById(R.id.line_row_number); nText.setText(linesShown.get(position).number()); GradientDrawable background=(GradientDrawable)nText.getBackground().mutate(); background.setColor(Color.parseColor(linesShown.get(position).color())); nText.setBackgroundDrawable(background); String txt; txt=linesShown.get(position).name(); ((TextView)convertView.findViewById(R.id.line_row_name)).setText(txt); } return convertView; } Merci par avance :). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.