为什么我的微调器没有在行中显示结果?

时间:2015-10-30 03:22:23

标签: java android

我有2个旋转器,一个是可用尺寸,一个是可用颜色。 为什么我的微调器没有在行中显示结果而是在列中显示结果。

ETC:

可用尺寸:

中(我想要的结果)

但我得到了这个 可用尺寸:小,中,大

以下是我的代码:

NearablesDemoActivity.java

private void displayCurrentNearableInfo() {
        stickerdb = new Database_sticker(this);
        dbRow = stickerdb.getResult(currentNearable.identifier);
        dbRow.getId();
        dbRow.getIdentifier();

        String[] size = stickerdb.getSize(currentNearable.identifier);
        ArrayAdapter<String> adapter= new ArrayAdapter<>
                (this,android.R.layout.simple_spinner_item, size);  //for size available
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerDropDown.setAdapter(adapter);

        String[] colour = stickerdb.getColour(currentNearable.identifier);
        ArrayAdapter<String> adapter1= new ArrayAdapter<>
                (this,android.R.layout.simple_spinner_item, colour); //for colours available
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerDropDown2.setAdapter(adapter1);


        String desc = dbRow.getDesc().toString();
        dbRow.getCa().toString();
        dbRow.getSa().toString();
        String coo = dbRow.getCoo().toString();
        String sm = dbRow.getSm().toString();
        String price = dbRow.getPrice().toString();


        //Set the text to the TextView
        Desc.setText(desc);
        COO.setText(coo);
        SM.setText(sm);
        Price.setText("$" + price);
    }

Database_sticker.java

 public String[] getSize(String identifier){
        String query = "SELECT * FROM " + TABLE_SRESULT + " WHERE " + KEY_IDENTIFIER + "='" + identifier + "'";
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(query, null);
        ArrayList<String> sizes = new ArrayList<String>();
        if(cursor.moveToFirst()){
            do{
                sizes.add(cursor.getString(3));

            }while(cursor.moveToNext());
        }
        return sizes.toArray(new String[sizes.size()]);
    }

    public String[] getColour(String identifier){
        String query = "SELECT * FROM " + TABLE_SRESULT + " WHERE " + KEY_IDENTIFIER + "='" + identifier + "'";
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(query, null);
        ArrayList<String> colours = new ArrayList<String>();
        if(cursor.moveToFirst()){
            do{
                colours.add(cursor.getString(4));
            }while(cursor.moveToNext());
        }
        return colours.toArray(new String[colours.size()]);
    }

    public Sresult getResult(String identifier) {
        String selectQuery = "SELECT * FROM " + TABLE_SRESULT + " WHERE " + KEY_IDENTIFIER + "='" + identifier + "'";
        SQLiteDatabase db = this.getWritableDatabase();   //open database
        Cursor cursor = db.rawQuery(selectQuery, null);
        //looping through all rows and adding to list
        Sresult sresult = new Sresult();
        if (cursor.moveToFirst()) {
            do {
                sresult.setId(Integer.parseInt(cursor.getString(0)));
                sresult.setIdentifier(cursor.getString(1));
                sresult.setDesc(cursor.getString(2));
                sresult.setSa(cursor.getString(3));
                sresult.setCa(cursor.getString(4));
                sresult.setCoo(cursor.getString(5));
                sresult.setSm(cursor.getString(6));
                sresult.setPrice(Float.parseFloat(cursor.getString(7)));
            } while (cursor.moveToNext());
        }
        return sresult;
    }

0 个答案:

没有答案