0

カーソルの形式で返されるDB値が入力されたスピナーがありますが、常に最初の値が選択されています。私が必要としているのは、最初のDB値の代わりに「None」値を持つことです。文字列がハードコーディングされている場合にこれを実行できることはわかっていますが、カーソルを使用してこれを実行するにはどうすればよいですか?

スピナーの私のコード-

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