0

我有一个微调器,其中填充了以 Cursor 形式返回的 DB 值。但它总是选择第一个值。我需要的是有一个“无”值而不是 od ffirst DB 值。我知道当我们有硬编码的字符串时我们可以做到这一点,但我怎么能用光标..?

我的微调器代码 -

Cursor c = listNamesDbHelper.fetchAllUserLists();
        startManagingCursor(c);
        Log.i(TAG, "cursor list names--->>" + c.getCount());
        // create an array to specify which fields we want to display
        String[] from = new String[c.getCount() + 1];
        from = new String[]{listNamesDbHelper.KEY_LIST_NAME};

        //from[0] = "None";
        // create an array of the display item we want to bind our data to
        int[] to = new int[]{R.id.ModifyTaskListNameItem};

        // create simple cursor adapter
        /*SimpleCursorAdapter adapter =
          new SimpleCursorAdapter(this, R.layout.choose_list_modify_task, c, from, to );
        adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );*/
        // get reference to our spinner

        CustomSpinnerItemsAdapter adapter = new CustomSpinnerItemsAdapter(this,c,from,to);
        Spinner s = (Spinner) findViewById( R.id.spinnerListSelection );
        s.setAdapter(adapter);

在此先感谢,雷

4

0 回答 0