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.

Icone dans titre d'un Dialog

Featured Replies

Posté(e)

Bonjour,

je me suis créé une fenêtre DialogInfo qui étend Dialog

en passant par mon layout en xml.

le titre de ma fenêtre se fait de cette façon:

setTitle("Titre de mon appli");

mais j'aimerais aussi y insérer une icône au même niveau (à gauche du titre) et je ne trouve pas comment faire.

J'ai essayé setFeatureDrawable... mais rien n'y fait.

Une idée ?

Merci

Posté(e)

voici un snippet de code, est-ce que tu y trouveras ton bonheur (si j'ai bien compris ta question) ?

=> ad.setIcon(R.drawable.icon);

public void ExitDialog(){

       AlertDialog.Builder ad = new AlertDialog.Builder(this);
       ad.setIcon(R.drawable.icon);
       ad.setTitle(R.string.ExitDialog_Title);
       ad.setMessage(R.string.ExitDialog_Message);

       ad.setPositiveButton(R.string.Yes, 
               new android.content.DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int arg1) {
               finish();
           }
       }
       );

       ad.setNegativeButton(R.string.No, 
               new android.content.DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int arg1) {
               //OK
           }
       }
       );

       ad.show();
   }

Posté(e)
  • Auteur

Merci mais justement je ne veux pas utiliser AlertDialog car si j'ai bien compris avec cette classe toute faite je ne peux pas faire un layout comme je veux...

Posté(e)

Alors 2 solutions :

  • Test d abord si ça ça marche :
requestWindowFeature (Window.FEATURE_LEFT_ICON);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
               android.R.drawable.XXXX);

  • Sinon tu peux toujours faire une dialog entièrement personnalisée. Regarde l'exemple "API Demo" dans le SDK, il y a un exemple qui montre comment faire (com.exemple.android.apis.app.DialogActivity).
Posté(e)
  • Auteur
Alors 2 solutions :

  • Test d abord si ça ça marche :
requestWindowFeature (Window.FEATURE_LEFT_ICON);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
               android.R.drawable.XXXX);

  • Sinon tu peux toujours faire une dialog entièrement personnalisée. Regarde l'exemple "API Demo" dans le SDK, il y a un exemple qui montre comment faire (com.exemple.android.apis.app.DialogActivity).

Salut merci pour ta réponse, je viens de tester la 1ère solution, ça plante pas mais ça ne fait rien :)

Suis en train de tester APIDemos....

Edit: Rectification la 1ère solution ne fonctionne pas, y a pas d'erreurs mais ma fenêtre ne s'affiche plus.

J'ai fais comme dans l'API Demo, j'ai changé l'héritage de ma classe, avant j'héritais de "Dialog" maintenant j'ai mis "Activity" mais, pareil la fenêtre ne s'affiche plus...

Modifié par cefabien

Rejoignez la conversation

Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.

Invité
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Répondre à ce sujet…

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.