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.

[Question][Problème]Spinner, list d'icone(image)

Featured Replies

Posté(e)

Bonjour a tous,

Après quelques recherches et expériences personnel je n'arrive toujours pas a ce que je voudrais, je m'explique:

Je fais actuellement une application " Paint like" et je cherche a faire un Spinner qui permettre de sélectionner une forme: rond, carré, crayon, Chaque possibilité étant représenté par une image.

J'ai cru comprendre via les divers exemples que j'ai trouvé et qui permette d'afficher un texte + un icone, qu'il faut que je crée un layout que voici :

<?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="vertical" >
<ImageView
 android:id="@+id/spinnerShape"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 />
</LinearLayout>

Je pensais utiliser un tableau de Bitmap pour contenir ma liste d'image :

arraySpinner = new Bitmap[4];
arraySpinner[0] = BitmapFactory.decodeResource(getResources(),R.drawable.square);
arraySpinner[0] = BitmapFactory.decodeResource(getResources(),R.drawable.circle);
arraySpinner[0] = BitmapFactory.decodeResource(getResources(),R.drawable.arrow);
arraySpinner[0] = BitmapFactory.decodeResource(getResources(),R.drawable.pencil);

Cependant je ne comprends pas comment mettre tout cela en relation avec mon Spinner.

Voila,si quelqu'un peut m’éclairer ou au moins me dire si ce que je tente de faire est possible ^^'

Merci d'avoir lu.

Posté(e)

Ce que tu veux faire est tout à fait possible. Il te faut utiliser un SimpleAdapter pour passer au Spinner les données à afficher

 List<Map<String,Integer>> datas = new ArrayList<Map<String,Integer>>();
 Map<String,Integer> line = new HashMap<String,Integer>();
 line.put("img", new Integer(R.drawable.square));
 datas.put(line);
 line = new HashMap<String,Integer>();
 line.put("img", new Integer(R.drawable.circle));
 datas.put(line);
 ...

 String[] from = { "img" };
 int[] to = { R.id.spinnerShape }
 SimpleAdapter adapter = new SimpleAdapter(this, datas, R.layout.nom_de_ton_layout, from, to);
 spinner.setAdapter(adapter);

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.