开发者

fill spinner with values of database - android

开发者 https://www.devze.com 2023-03-06 07:05 出处:网络
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.

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

精彩评论

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

关注公众号