开发者

fill spinner with values of database - android

i try to put some entries of my db into a spinner. i googled and found some code. my problem: it doesn't work for me.

Any ideas what i do wrong?

        Cursor myCursor = myDB.rawQuery("SELECT _id, name FROM Car;", null);

        startManagingCursor(myCursor);

        myCursor.moveToFirst();


        SimpleCursorAdapter spinneradapt = new SimpleCursorAdapter(
                this, 
                android.R.layout.simple_spinner_item, 
                myCursor,
                new String[] { "name" }, 
                new int[] {android.R.id.text1});

        spinneradapt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spnName.setAdapter(spinneradapt);

i "toasted" (<- haha :D) the first entry of my db. it works fine. but there are no entries in my spinner..

Thanks,开发者_运维问答 Prexx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜