IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants graphiques Android Discussion :

Charger une image d'une base de données dans un image view


Sujet :

Composants graphiques Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2014
    Messages : 13
    Points : 10
    Points
    10
    Par défaut Charger une image d'une base de données dans un image view
    Bonjour a tous,
    svp j'aimerais charger une image qui se trouve dans un dossier(images) pour l'afficher dans un imageview, mais j'ai une erreur "E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /images/Uploads/Suspect/Profile/rtrt4.jpg: open failed: ENOENT (No such file or directory)".
    ou dois je placer le dossier contenant les images?ou comment proceder??

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    83
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 83
    Points : 51
    Points
    51
    Par défaut
    Bonjour,
    Quel est ton code ?

  3. #3
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2014
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    String z = result.getString("imagePath");
     
    img.setImageBitmap(BitmapFactory.decodeFile(z));

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    83
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 83
    Points : 51
    Points
    51
    Par défaut
    Tu codes avec quel logiciel ?
    Peux tu donner ton java et ton xml en entier ?

  5. #5
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2014
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    j'utilise android studio et genymotion comme emulateur;voici le code java et xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    public class DoLogin extends AsyncTask<String,String,String> {
            String z="";
            Boolean isSucces = false;
            Statement state;
            ResultSet result;
            @Override
            protected  void onPreExecute(){
                //mProgressBar.setVisibility(View.VISIBLE);
     
            }
            @Override
            protected  void onPostExecute(String r){
                if(isSucces) {
                    try {
     
     
                        nSuspect.setText(result.getString("Lname"));
                        pSuspect.setText(result.getString("Fname"));
                        //numSuspect.setText(result.getString("NumeroCarte"));
                       // numSuspect.setText("good");
                        seSuspect.setText(result.getString("sexe"));
                        affSuspect.setText(result.getString("AffaireName"));
    //partie de l'image
                        String z = result.getString("imagePath");//recuperation du patrh de limage
     
     
     
     
                        img.setImageBitmap(BitmapFactory.decodeFile(z));
     
     
                    }
     
                    catch (MalformedURLException e) {
                      e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    catch (Exception ex)
                    {
                       // numSuspect.setText(ex.getMessage());
                    }
                }
                else {
     
                }
            }
            @Override
            protected String doInBackground(String...params){
     
                String querry = " SELECT P.Lname,P.Fname,P.NumeroCarte,P.sexe,P.imagePath,P.AffaireId,A.ID,A.AffaireName,U.usernames,U.centerId  FROM  AndroidUsers U,P_Impliquer P INNER JOIN NAffaires  A ON A.ID=P.AffaireId WHERE P.ID='" + value + "' and U.usernames= '"+name+"' ";
                try {
                    Connection con = connectionClass.CONN();
                    if (con == null) {
                        //  z = "Erreur de connection";
                    } else {
                        state = con.createStatement();
                          result = state.executeQuery(querry);
                        if (result.next()) {
     
     
                            z="Login Succes";
                            isSucces=true;
     
     
     
     
     
     
     
     
                        } else {
                            z="Login failed";
                            isSucces=false;
     
                        }
                    }
                } catch (Exception ex) {
     
                }
                return z;
     
            }
     
     
        }
    Le xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
     
        <LinearLayout
     
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <include
                android:id="@+id/app_bar"
     
                layout="@layout/app_bar"/>
            <ScrollView
     
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:background="#ffffff">
     
                <LinearLayout
     
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
     
                    <LinearLayout
     
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:paddingBottom="15dp"
                        android:layout_height="match_parent"
                        android:weightSum="1">
     
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="40dp"
     
                            android:textColor="#7fc8f6"
                            android:layout_centerInParent="true"
                            android:text="Details :"
                            android:gravity="center_horizontal"
                            android:textStyle="bold|italic"/>
     
                        <ImageView
                            android:id="@+id/imageview"
                            android:layout_width="80dp"
                            android:layout_height="90dp"
     
     
                             />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="Nom :"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="30dp"
                            android:id="@+id/nSuspect"
                            android:textColor="#4141a0"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="PreNom :"   android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="30dp"
                            android:id="@+id/pSuspect"
                            android:textColor="#4141a0"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            />
     
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="Numero CNI :"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="30dp"
                            android:id="@+id/numSuspect"
                            android:textColor="#4141a0"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="Sexe :"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="30dp"
                            android:id="@+id/seSuspect"
                            android:textColor="#4141a0"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="Statut :"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:id="@+id/stt"
                            android:textColor="#cf1f07"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            android:text="Rechercher par nos Services"
                            />
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:textColor="#000000"
                            android:layout_centerInParent="true"
                            android:text="Affaire Implique :"
                            android:layout_marginTop="15dp"
                            />
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textSize="30dp"
                            android:id="@+id/affSuspect"
                            android:textColor="#4141a0"
                            android:layout_centerInParent="true"
                            android:layout_marginTop="15dp"
                            />
     
     
     
     
                    </LinearLayout>
                </LinearLayout>
            </ScrollView>
        </LinearLayout>
    </LinearLayout>

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    83
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 83
    Points : 51
    Points
    51
    Par défaut
    Si je comprends bien, tu cherches à charger une image par url et non en local. C'est ça ?

    (attention ton ip est une ip local, active le wifi) dans ton appli ?

    ps: pense à utiliser les balises code : # , ce sera plus lisible.

  7. #7
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2014
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    le wif est bien activer quand meme, ok voici le concept, c'est une application web qui enverra les images dans un dossier sur le serveur, et a partir de cet application android, je vais vais afficher l'image correspondant a un nom cliquer, pour le moment jai creer un dosier image que j'ai mis le "res" de mon projet, et le chemin stocker dans une base de donne sql server, maintenant j'aimerais par exemple que quand on saisi un nom dans l'editview j'affiche l'image correspondant, pour le moment j'arrive a faire des requete pour afficher just le path de l'image"/images/Uploads/Suspect/Profile/rtrt4.jpg" comment le decoder dans limage view?jai just l'android studio et la base de donnee...

Discussions similaires

  1. récupérer une valeur de la base de données dans une liste
    Par Marie_7 dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 30/06/2015, 18h46
  2. Réponses: 1
    Dernier message: 21/10/2013, 18h54
  3. Réponses: 14
    Dernier message: 25/07/2013, 10h29
  4. Réponses: 12
    Dernier message: 05/11/2010, 17h58
  5. Réponses: 3
    Dernier message: 12/07/2010, 11h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo