如何在listview中添加微调器

时间:2011-07-01 14:12:49

标签: android spinner

我希望listview中的每一行都有一个微调器。但不能。请帮帮我。

//Setting player        
 adapter = new SimpleAdapter(this, list, R.layout.custom_listitem_edit,
                    new String[] {  "cat", "duration", "order", "id_pos"}, new int[] {
                            R.id.spn_edibt_selectcat,
                            /*R.id.spn_editbt_selectpos,*/
                            R.id.txt_editbt_dur, 
                            R.id.txt_editbt_order,
                            R.id.txt_edit_idpos
                            });



    populateList();
            setListAdapter(adapter);




    static final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();


    /* Set thong tin cho listview */
    private void populateList() {

        cursor_position_mycurrent = dbHelper_position_mycurrent.fetchAllPositionMyCurrentById(id_bt);
        startManagingCursor(cursor_position_mycurrent);

        Log.e("SO dong lay duoc la", String.valueOf(cursor_position_mycurrent.getCount()));


        if (cursor_position_mycurrent != null) {
            cursor_position_mycurrent.moveToFirst();
            while (cursor_position_mycurrent.isAfterLast() == false) {
                HashMap<String, String> tmp = new HashMap<String, String>();


                Log.e("DUR", cursor_position_mycurrent.getString(5));
                Log.e("DUR", cursor_position_mycurrent.getString(6));

                tmp.put("duration", cursor_position_mycurrent.getString(5));                
                tmp.put("order", cursor_position_mycurrent.getString(6));
                tmp.put("id_pos", cursor_position_mycurrent.getString(0));


                //Setting spinner category
                cursor_position_allposition =dbHelper_position_allposition.fetchAllPositions();    
                array_spinner_category = new String[cursor_position_allposition.getCount()];


                if (cursor_position_allposition != null) {
                    int i = 0;
                    cursor_position_allposition.moveToFirst();
                    while (cursor_position_allposition.isAfterLast() == false) {
                        array_spinner_category[i] = cursor_position_allposition.getString(0);               
                        cursor_position_allposition.moveToNext();
                        i++;
                    }
                    cursor_position_allposition.close();
                }           


                Log.e("ALL POS", String.valueOf(cursor_position_allposition.getCount()));

                Spinner spinner = (Spinner) findViewById(R.id.spn_edibt_selectcat);

                int m = 3;//Integer.parseInt(camping.rulesList.getMaxPers().get(camping.tipSel));

                String[] array_spinner=new String[m];
                for (int indice = 0; indice < m; indice++)
                {
                    if (indice == 0) array_spinner[indice] = String.format("%d persona", indice+1);
                    else array_spinner[indice] = String.format("%d persone", indice+1);
                }

               final  ArrayAdapter<String> aa = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, array_spinner);
                aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                spinner.setAdapter(aa);



                list.add(tmp);
                cursor_position_mycurrent.moveToNext();

            }

        }
    }

0 个答案:

没有答案