PDA

Ver la Versión Completa : Pasar datos a un array


Napster87
18/02/14, 11:35:34
Mi ultimo intento,ya que no consigo hacerlo funcionar desde hace semanas.

Tengo una bd,extraigo los datos sin problema,teniendo el id de la fila que quiero manejar:

dbAdapter = new HipotecaDbAdapter(this);
dbAdapter.abrir();
id = extra.getLong(HipotecaDbAdapter.C_COLUMNA_ID);
cursor = dbAdapter.getRegistro(id);
Log.i("IDENTIFICADOR BD ","EL ID ES: "+id);
Hasta ahi bien,en el id almaceno la posicion que me interesa,esta incluye un campo C_COLUMNA_FOTOS,que siendo string lo almaceno asi: R.drawable.foto1,R.drawable.foto2..etc.

Lo que ahora quiero hacer es pasar ese cursor a un array final que es integer,para mostrar las fotos,estoy intentandolo asi:

ArrayList<String> array = new ArrayList<String>();
array.add(cursor.getString(cursor.getColumnIndex(H ipotecaDbAdapter.C_COLUMNA_FOTOS)));
mString = (String[]) array.toArray(new String[array.size()]);

mString lo pasaria a un Viewpageradapter para mostrar las imagenes...

ViewPagerAdapter adapter = new ViewPagerAdapter(Tab3Up.this,mString);

Y finalmente:

public class ViewPagerAdapter extends PagerAdapter {

Activity activity;
Integer imageArray[];

public ViewPagerAdapter(Activity act,Integer []mString) {
imageArray = mString;
activity = act;
}

public int getCount() {
return imageArray.length;
}

public Object instantiateItem(View collection, int position) {
ImageView view = new ImageView(activity);
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
view.setScaleType(ScaleType.FIT_XY);
view.setBackgroundResource(imageArray[position]);


Esa es la idea,para que se vea el flujo...como convertirlo adecuadamente a integer?
Agradezco cualquier idea,no se por donde seguir ya..