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.

findById me renvoie un type inconnu

Featured Replies

Posté(e)

Bonjour,

je suis bloqué depuis un petit moment sur le problème suivant :

J'ai un fichier main.xml qui contient toute la structure de mon UI.

Dans cette structure, se trouve une ScrollView :

<ScrollView android:id="@+id/scrollview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

Dans mon code, je souhaite créer un objet ScrollView qui reprend cette structure, je fais donc un :

ScrollView scrollV = (ScrollView) findViewById(R.id.scrollview1);

Mais en débuguant, je remarque que mon objet scrollV est null, car R.id.scrollview1 a apparemment un type inconnu (>Unkown type "me.georgesleyeti.androidapp.R$id").

Est-ce que je fais quelque chose de faux ?

Merci d'avance.

Modifié par georgesleyeti

Posté(e)
  • Auteur

Si scrollV est null, c'est que findViewById ne le trouve pas dans la structure de la vue. Appelle-tu bien cette méthode dans le bon contexte (l'Activity/la View qui correspond à ton main.xml) ?

Hmmpf ,... merci, j'viens de remarquer que j'avais effacé le setContentView(R.layout.main);

ça marche mieux en le remettant :o

Modifié par georgesleyeti

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.