1

我有三个spinner相同的习惯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));

当我打电话时(例如):

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

所有三个旋转器setSelection都像最后一个......在位置3。为什么?

所有微调器具有相同的数据(一个光标)

4

2 回答 2

0

所有三个对象都指向同一个实例吗?(与从 XML 加载的资源相同)

于 2013-10-02T19:52:25.863 回答
0

问题解决了,但我不明白为什么这很重要,因为

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

解决方案,像这样设置适配器:

        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));
于 2013-10-03T06:20:23.937 回答