如何设置自定义微调器的值 android

How to set value of custom spinner android

因此,我根据 (Android - configure Spinner to use array) and (http://www.katr.com/article_android_spinner01.php)
中的教程创建了自定义微调器 她是我的代码示例

      getAkun.getAkunUserKategori(data,tipee, new Akun_Get.dataCallBack() {
        @Override
        public void getData(List<tblAkunDatabase> value) {
            result = value;
            List<spinerAkun> daatspiner;
            daatspiner = new ArrayList<spinerAkun>();
            for(int i = 0;i< result.size();i++)
            {
                daatspiner.add(new spinerAkun(result.get(i).getKdAkun(),result.get(i).getNmAkun()));

                ArrayAdapter<String> adapter = new ArrayAdapter(Edit_Jurnal.this, android.R.layout.simple_dropdown_item_1line, daatspiner);
                spin.setAdapter(adapter);

            }

        }

    });

所以,实际上它正在工作。但问题是当我尝试从数据库中设置微调器值时。通过使用 spin.setSelection(daatspiner.indexof("datafromdatabase")) 。但是它得到一个错误"android.content.res.Resources$NotFoundExceptionn: String resource ID #0xffffffff at ....."。所以要解决这个问题?谢谢

更新

好的,我不知道这是否真的解决了我的问题。但是我双赢的解决方案是创建另一个数组,这样我就可以从 tatx 数组中获取索引并将 taht 数组中的索引用于我的微调器 spin.setSelection(Arrays.asList(array).indexOf("value"))

我的双赢解决方案是创建另一个数组,这样我就可以从 tatx 数组中获取索引并将 taht 数组中的索引用于我的微调器 spin.setSelection(Arrays.asList(array).indexOf("value"))