Lorem Ipsum/DOL Differet Solmena

Separat existentie 2010 Unee MYT por scientie, musica, sport etc, litot Europa usa li sam Vocabular Lingues, differe solmen in li grammatica, li pronunciation. Delete this widget in Dashboard and add yours. This is just an example. Read More

[gtug-bsas] Duda Android Ajax GridView

domingo, 22 de junio de 2014

Hola Chicos!

Estoy teniendo un problema que creo que es un tema de procesos asincronos.
Primero, armo un gridView por xml y lo instancio en mi clase.
gridView = (GridView) findViewById(R.id.gridView);

Luego, llamo a una api mia para que traiga unas imagenes.
String url = String.format("URL de la api");
new obtainImg().execute(url);

Dentro de la funcion obtainImg(), llamo a un gridAdapter para poder meterlas.
 protected void onPostExecute(String response) {    
    try {
    JSONArray img = new JSONArray(response);
customGridAdapter = new GridViewAdapter(MainActivity.this, R.layout.row_grid, getData(img));
} catch (JSONException e) {
e.printStackTrace();
}  
   }

Se mete a la funcion getData() y llena los datos para las imagenes.
private ArrayList<ImageItem> getData(JSONArray img) {
final ArrayList<ImageItem> imageItems = new ArrayList<ImageItem>();
// retrieve String drawable array
TypedArray imgs = getResources().obtainTypedArray(R.array.image_ids);
for (int i = 0; i < imgs.length(); i++) {
Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),
imgs.getResourceId(i, -1));
imageItems.add(new ImageItem(bitmap, "Image#" + i));
}

return imageItems;
}

Actualmente estoy usando datos locales, no de la api, y funcionaba todo bien. Ahora que meti la llamada, la app queda en blanco, como que nunca termina de armar el customGrid.

--
Has recibido este mensaje porque estás suscrito al grupo "GTUG Buenos Aires | Google Developers Group" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a gtug-bsas+unsubscribe@googlegroups.com.
Para acceder a más opciones, visita https://groups.google.com/d/optout.

0 comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.