Question

I have three spinner with same custom SimpleCurosAdapter

    spinnerX = (Spinner)findViewById(R.id.spinnerX);
    spinnerY = (Spinner)findViewById(R.id.spinnerY);
    spinnerZ = (Spinner)findViewById(R.id.spinnerZ);
    spinnerX.setAdapter(new SpinnerAd(this, R.layout.my_item, c, from, to));
    spinnerY.setAdapter(new SpinnerAd(this, R.layout.my_item, c, from, to));
    spinnerZ.setAdapter(new SpinnerAd(this, R.layout.my_item, c, from, to));

And when i call (for example):

    spinnerX.setSelection(1);
    spinnerY.setSelection(7);
    spinnerZ.setSelection(3);

ALL three spinners setSelection like last one... at position 3. Why?

All spinners has same data (one cursor)

Was it helpful?

Solution 2

Problem solved, but i do not understand why does it matter, becouse

c == dbRead.query(CalcDBHelper.TABLE_VARIABLES, null, null, null, null, null, null);

Solution, set adapter like this:

        spinnerX.setAdapter(new SpinnerAd(this, R.layout.formula_variable_item, ActMain.dbRead.query(CalcDBHelper.TABLE_VARIABLES, null, null, null, null, null, null), from, to));
        spinnerY.setAdapter(new SpinnerAd(this, R.layout.formula_variable_item, ActMain.dbRead.query(CalcDBHelper.TABLE_VARIABLES, null, null, null, null, null, null), from, to));
        spinnerZ.setAdapter(new SpinnerAd(this, R.layout.formula_variable_item, ActMain.dbRead.query(CalcDBHelper.TABLE_VARIABLES, null, null, null, null, null, null), from, to));

OTHER TIPS

Do all three objects point to the same instance ? (the same resource as loaded from the XML)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top