Android微调器问题

时间:2010-12-07 15:44:41

标签: android spinner

我在活动中实施了一个Spinner,列出了可供选择的货币。但是,当选择任何货币时,它会将值返回为“database.sqlite.sqlitecursor @”。

如何让它显示实际字符串而不是当前结果?

这是代码:

private void fillSpinnerData() {
    String[] fields = new String[]  {   db.CURRENCY_CODE    };
    int[] views = new int[] {   android.R.id.text1 /*R.id.text1, R.id.text2*/   };

    c = db.getAllCurrencies();
    startManagingCursor(c);

    currencySpinner = (Spinner)findViewById(R.id.spnChangeCurrency);

    SimpleCursorAdapter currencies = new SimpleCursorAdapter(
            this,
            android.R.layout.simple_spinner_item,
            c, fields, views);

    currencies.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    currencySpinner.setAdapter(currencies);

    currencySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
        {
            String index = currencySpinner.getSelectedItem().toString();
            Toast.makeText(getBaseContext(),
                "You have selected item : " + index + " which is row " + id,
                Toast.LENGTH_LONG).show();
        }

        public void onNothingSelected(AdapterView<?> arg0) {}
    });

}

提前致谢。

1 个答案:

答案 0 :(得分:0)

看起来像question has the answer