Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Spinner personnalisé, couleur s'affiche en noir

Featured Replies

Posté(e)

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 :).

Modifié par Sylvain-a

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.