Q: Android working with custom view I've a activity class like this:
public class MainActivity extends Activity {

    private DbAdapter db;
    private ArrayList<Integer> scelte;
    private ArrayList<Schedina2> schedine;
    private Schedina2 schedina1;
    private Schedina2 schedina2;
    private Schedina2 schedina3;
    private Schedina2 schedina4;
    private Schedina2 schedina5;
    private Schedina2 schedina6;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);

        scelte = new ArrayList<Integer>();
        schedine = new ArrayList<Schedina2>();

        db = new DbAdapter(this);
        Log.d("DB", "Connessione al DB...");
        db.open();
        Log.d("DB", "connesso ! ");

        scelte.add(1);
        scelte.add(2);
        scelte.add(3);
        scelte.add(4);
        scelte.add(5);
        scelte.add(6);
        scelte.add(7);

        schedina1 = (Schedina2)findViewById(R.id.schedina1);
        schedina2 = (Schedina2)findViewById(R.id.schedina2);
        schedina3 = (Schedina2)findViewById(R.id.schedina3);
        schedina4 = (Schedina2)findViewById(R.id.schedina4);
        schedina5 = (Schedina2)findViewById(R.id.schedina5);
        schedina6 = (Schedina2)findViewById(R.id.schedina6);
        for (int i = 0; i < scelte.size(); i++) {
            schedine.add(new Schedina2(getBaseContext().getApplicationContext()));
            setSchedina(scelte.get(i),schedine.get(i));//schedine.get(i).setScheda(fillArray(c));
        }
        // 1
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(0)); 
        //                          setSchedina(scelte.get(0),schedina1);
        schedina1=schedine.get(0);
        schedina1.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(0));

        // 2
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(1)); 
        //                          setSchedina(scelte.get(1),schedina2);
        schedina2=schedine.get(1);
        schedina2.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(1));

        // 3
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(2)); 
        //                          setSchedina(scelte.get(2),schedina3);
        schedina3=schedine.get(2);
        schedina3.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(2));

        // 4
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(3)); 
        //                          setSchedina(scelte.get(3),schedina4);
        schedina4=schedine.get(3);
        schedina4.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(3));

        // 5
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(4)); 
        //                          setSchedina(scelte.get(4),schedina5);
        schedina5=schedine.get(4);
        schedina5.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(4));

        // 6
        //                          Log.d("Schedina", "Recupero schedina numero "+ scelte.get(5)); 
        //                          setSchedina(scelte.get(5),schedina6);
        schedina6.postInvalidate();
        Log.d("Schedina", "Refresh schedina numero "+ scelte.get(5));

    }


    private void setSchedina(int index, Schedina2 schedina ){


        Log.d("FillArray", "chiamo fillArray per index = "+ index);
        Cursor c = db.getContact(index);
        if (c.isFirst()) {
            int[] b = new int[28];
            for (int i = 0; i <28 ; i++)
                b[i] = Integer.parseInt((String) c.getString(i));
            c.close();
            String debug ="Array = ";
            for (int j = 0; j <b.length ; j++)
                debug += b[j]+"-";

            Log.d("FillArray", debug);
            schedina.setScheda(b);
        } else {
            Log.d("FillArray", "Errore fillArray per index = "+ index);
        }
    }
}

when try to run the application I see in logcat the follow messages:
07-08 11:17:23.355: D/FillArray(3277): chiamo fillArray per index = 7
07-08 11:17:23.376: D/FillArray(3277): Array = 7-0-12-20-32-41-0-0-72-0-5-0-0-35-47-53-0-74-0-0-17-22-0-0-0-61-75-83-
07-08 11:17:23.376: D/Schedina(3277): Refresh schedina numero 1
07-08 11:17:23.385: D/Schedina(3277): Refresh schedina numero 2
07-08 11:17:23.385: D/Schedina(3277): Refresh schedina numero 3
07-08 11:17:23.385: D/Schedina(3277): Refresh schedina numero 4
07-08 11:17:23.385: D/Schedina(3277): Refresh schedina numero 5
07-08 11:17:23.385: D/Schedina(3277): Refresh schedina numero 6
07-08 11:17:23.665: D/gralloc_goldfish(3277): Emulator without GPU emulation detected.
07-08 11:17:23.775: D/Schedina 0(3277): Scheda numero 0
07-08 11:17:23.775: D/Schedina 0(3277): Scheda numero 0
07-08 11:17:23.785: D/Schedina 0(3277): Scheda numero 0
07-08 11:17:23.785: D/Schedina 0(3277): Scheda numero 0
07-08 11:17:23.806: D/Schedina 0(3277): Scheda numero 0
07-08 11:17:23.806: D/Schedina 0(3277): Scheda numero 0

I want to display a View with number like this:
import junit.framework.Test;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TableLayout.LayoutParams;
import android.widget.TableRow;

public class Schedina2 extends View {

    private RectF rectangle;
    private Paint paint;
    private Paint testo;
    private RectF[] schede;
    private int numeroScheda;
    private int[] numeri;
    private Paint[] sfondo;
    private int[] punteggio;
    private Canvas canvas;
    private int margin = 2;
    private int offset = 30;
    private int width = 30;
    private int height = 50;
    private int left_margin = 10;
    private int spazio;
    private Paint numeriTxt;

    public Schedina2(Context context) {
        super(context);
        all();
    }

    public int[] getPunteggio() {
        return punteggio;
    }



    public Schedina2(Context context, AttributeSet attrs) {
        super(context, attrs);
        all();
    }


    public Schedina2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        all();

    }



    private void all() {
        numeriTxt = new Paint();
        numeriTxt.setColor(Color.BLACK);
        numeriTxt.setTextSize(17);
        spazio = 32;
        numeroScheda=0;
        rectangle = new RectF();
        paint  = new Paint();
        testo = new Paint();
        punteggio= new int[3];
        numeri= new int[27];
        schede = new RectF[28];
        sfondo = new Paint[28];
        for (int i=0; i<27 ;i++) {
            schede[i] = new RectF();
            sfondo[i] = new Paint();
        }
        rectangle.set(0, 0, 303, 200  );
        testo.setColor(Color.WHITE);
        testo.setTextSize(18);
        paint.setColor(Color.BLACK);
        paint.setStrokeWidth(2);
        Log.d("Schedina", "all fine");
    }

    @Override
    protected void onDraw(Canvas canvas) {
        this.canvas = canvas;
        canvas.drawRoundRect(rectangle, 0, 0, paint);

        for (int i=0; i<27 ;i++) {
            int mod = (i%9);
            if (i < 9 )
                schede[i].set((width*i)+(margin*i)+left_margin, margin+offset, (width*i)+(margin*i)+width+left_margin, height+margin+offset);
            //                 schede[i].set((width*i)+(margin*i), margin+offset, (width*(i+1))+(margin*i), height+margin+offset);
            else if (i < 18 )
                schede[i].set(left_margin+(width*mod)+(margin*mod), height+(margin*2)+offset, left_margin+(width*mod)+(margin*mod)+width, (height*2)+(margin*2)+offset);
            else if (i < 27 )
                schede[i].set(left_margin+(width*mod)+(margin*mod), (height*2)+(margin*3)+offset, left_margin+(width*mod)+(margin*mod)+width, (height*3)+(margin*3)+offset);
            sfondo[i].setColor(Color.LTGRAY);
            canvas.drawRect(schede[i], sfondo[i]);
            if (numeri[i] > 0) {
                if ( i < 9  )
                    canvas.drawText(Integer.toString(numeri[i]), 15+(spazio*i), 60, numeriTxt);
                else if (i < 18  )
                    canvas.drawText(Integer.toString(numeri[i]), 15+(spazio*(i%9)), 115, numeriTxt);
                else if (i < 27  )
                    canvas.drawText(Integer.toString(numeri[i]), 15+(spazio*(i%9)), 170, numeriTxt);
            }
        }
        canvas.drawText("Scheda N: "+numeroScheda, 100, 25, testo);
        Log.d("Schedina "+numeroScheda, "Scheda numero "+ numeroScheda);

    }


    public void setScheda(int[] array){

        for (int i = 0; i< array.length ; i++){
            if (i == 0)
                numeroScheda = array[0];
            else if (i > 0) { 
                numeri[i-1]= array[i];
            }
        }
    }


    public void setEstratto(int numero){
        for (int i = 1; i< numeri.length ; i++){
            if (numeri[i] == numero) {
                sfondo[i-1].setColor(Color.RED);
                punteggio[(int) ((i-1)/9)]++;
                Log.d("Estratto", "trovato estratto "+ numero+" punteggio = " + (punteggio[0]+punteggio[1]+punteggio[2]));
                break;
            }
        }
    }
}

but i've a void customView without the numbers the i set in the Activity.

A: If you want to iterate through cursor you should use moveToFirst() and moveToNext()
Cursor cursor = db.getContact(index);
if (cursor != null && cursor.moveToFirst()) {
    do {
        ...                 
    } while (cursor.moveToNext());
}

if getContact(index) returns only one row first check if cursor != null and then use cursor.moveToFirst() to get your row data.
