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.

Problème affichage dans une ImageView

Featured Replies

Posté(e)

Bonsoir :) ,

J'affiche des images dynamiquement dans une ImageView en carré grace au paramètre android:scaleType="centerCrop".

ça marche correctement mais quand je recommence l'opération pour la quatrieme fois l'application crash inexplicablement...quand je la relance et reessaye avec la même image ça marche. ça vient surement donc de la liberation de la mémoire de l'imageView..

Voici le XML:

   android:id="@+id/profilpic"
   android:layout_height="110px" 
   android:layout_width="110px"
   android:scaleType="centerCrop"
   android:src="@drawable/facepicture"
   android:layout_marginLeft="10px"
   android:layout_marginTop="12px"
   >

et dans le fichier source:

 i = new Intent(Intent.ACTION_PICK);
          i.setType(MediaStore.Images.Media.CONTENT_TYPE);

          ((ImageButton)findViewById(R.id.buttonMyspace)).setOnClickListener(new OnClickListener(){

              public void onClick(View v) {

                  startActivityForResult(i, REQUEST_CODE_SELECT_PICTURE);

              }            

          });


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);

   if (requestCode == REQUEST_CODE_SELECT_PICTURE)
   {
       if (resultCode == RESULT_OK)
       {
           Uri uri = data.getData();

           if (uri != null)
           {
               try
               {
                   Bitmap bm = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri));
                   ImageView face = ((ImageView)findViewById(R.id.profilpic));
                   face.setImageBitmap(bm);

               }
               catch (FileNotFoundException e)
               {
                   e.printStackTrace();
               }
           }
       }
   }
}

Si quelqu'un a une idée?

merci,

Florent

Modifié par FlorentCode

Posté(e)
  • Auteur

Personne?

Je crois que les images s'accumulent dans l'imageView , il faudrait faire un clean de l'imageView. Pour cela, j'ai tenté de faire un

((ImageView)findViewById(R.id.profilpic)).setImageBitmap(NULL);

Mais ça plante toujours à la quatrieme photo.

Posté(e)

Bonjour,

Quelle est l'exception qui est levée ?

Dans ce genre d'utilisation, il faut faire attention à la taille des images qui à tendance à exploser l'espace mémoire alloué. Vu la fréquence constante de l'erreur, cela peut-être une piste.

Bone courage,

ichpa

Modifié par ichpa

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.