Bonjour,

Lorsque je récupère mes images au format bitmap, depuis ma base de données. Ensuite je les mets dans une galerie et quand j’exécute, mes 2 premières images ne sont pas affichées au premier coup. Par contre, lorsque je fais défiler la galerie les images apparaissent.

Je ne sais pas comment faire dans la méthode getView(.....) pour qu'elles soient affichées dans la galerie.

Voici des images et le code

Nom : 0.JPG
Affichages : 92
Taille : 29,0 Ko Nom : 00.JPG
Affichages : 94
Taille : 30,2 Ko
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
public class MainActivity extends Activity {
 
    private ProgressDialog pDialog;
 
    JSONParser jsonParser = new JSONParser();
 
    int success = 0;
 
    // url to create new product
 
    // JSON Node names
    private static final String TAG_SUCCESS = "success";
 
    InputStream is;
 
    Bitmap bitmapOrg;
    String result = "";
    Bitmap bitmap;
 
    ImageView imageView;
    @SuppressWarnings("deprecation")
    Gallery ga;
    Bitmap[] bity = new Bitmap[10];
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ga = (Gallery) findViewById(R.id.Gallery01);
        imageView = (ImageView) findViewById(R.id.ImageView01);
 
        new Reccuperer().execute();
 
        ga.setAdapter(new ImageAdapter(getApplicationContext()));
 
        Toast.makeText(getApplicationContext(), "hihohahy", Toast.LENGTH_LONG).show();
 
        ga.setOnItemClickListener(new OnItemClickListener() {
 
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
 
                imageView.setImageBitmap(bity[arg2]);
 
            }
        });
 
    }
 
    class Reccuperer extends AsyncTask<String, String, String> {
 
        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(MainActivity.this);
            pDialog.setMessage("Chargement en cours..");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }
 
        /**
         * Creating product
         * */
        protected String doInBackground(String... args) {
 
            String str1 = "";
 
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
 
            JSONObject json = jsonParser.makeHttpRequest(
                    "http://10.0.2.2/M3alemApp/reccupereimage.php", "POST",
                    params);
 
            // check log cat fro response
            Log.d("Success", json.toString());
 
            try {
                success = json.getInt(TAG_SUCCESS);
                if (success == 1) {
 
                    for (int i = 0; i < json.getJSONArray("picture").length(); i++) {
                        str1 = json.getJSONArray("picture").getJSONObject(i)
                                .getString("image");
                        byte[] ba2 = Base64.decode(str1);
 
                        bitmap = BitmapFactory.decodeByteArray(ba2, 0,
                                ba2.length);
 
                        bity[i] = bitmap;
 
                    }
 
                } else {
 
                }
 
            } catch (JSONException e) {
                Log.e("log_tag", "Error parsing data " + e.toString());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
            return null;
        }
 
        /**
         * Aimg2.setImageBitmap(bitmap);fter completing background task Dismiss
         * the progress dialog
         * **/
        protected void onPostExecute(String file_url) {
            // dismiss the dialog once done
            pDialog.dismiss();
 
            Log.d("Taille: ", "" + bity.length);
 
        }
 
    }
 
    class ImageAdapter extends BaseAdapter {
 
        private Context ctx;
        int imageBackground;
 
        public ImageAdapter(Context c) {
            ctx = c;
            TypedArray ta = obtainStyledAttributes(R.styleable.Gallery1);
            imageBackground = ta.getResourceId(
                    R.styleable.Gallery1_android_galleryItemBackground, 1);
            ta.recycle();
 
        }
 
        @Override
        public int getCount() {
 
            return bity.length;
        }
 
        @Override
        public Object getItem(int arg0) {
 
            return arg0;
        }
 
        @Override
        public long getItemId(int arg0) {
 
            return arg0;
        }
 
        @Override
        public View getView(int arg0, View arg1, ViewGroup arg2) {
            ImageView iv = new ImageView(ctx);
            if (arg1 != null ) 
            {   
 
                for(int i1=0;i1<getCount();i1++)
                {
 
                    iv.setImageBitmap(bity[i1]);     
                }
 
            }
            else
            iv.setImageBitmap(bity[arg0]);
            iv.setScaleType(ImageView.ScaleType.FIT_XY);
            iv.setLayoutParams(new Gallery.LayoutParams(150, 120));
            iv.setBackgroundResource(imageBackground);
            this.notifyDataSetChanged();
            return iv;
        }
 
    }
}
Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?

Merci d'avance pour votre aide.