对话框中的微调框,包含fillwindow()中的无效语句

时间:2012-04-03 16:05:34

标签: android android-alertdialog android-spinner

我的代码有问题。我在一个警告对话框中实现了一个微调器,但当我显示它是白色时,日志猫说:

04-03 15:56:17.119: E/Cursor(460): Invalid statement in fillWindow()

我能做些什么来解决它?这是代码。我从另一个活动中复制了它。但在这项活动中却没有。为什么???

Cursor sp_curs;

    Dialog viewDialog = new Dialog(this);

    viewDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

    viewDialog.setTitle("Select Category");

    LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogView = li.inflate(R.layout.spinner_alert, null);

    Spinner spinnercategory = (Spinner) dialogView
            .findViewById(R.id.spinQ);

    //Apriamo il db creato tramite MissioniDb a cui passo il contesto della classe attuale ovvero Lista_Missioni
    SpinnerDb sdb=new SpinnerDb(getApplicationContext());

    //apriamo il db
    sdb.open();  

    //Chiamo la Query che in questo caso è un all
    sp_curs=sdb.fetchSPINNER();

    startManagingCursor(sp_curs);

    // create an array to specify which fields we want to display
    String[] from = new String[]{SpinnerDb.SpinnerMetaData.SPINNER_CAT_KEY};

    // create an array of the display item we want to bind our data to
    int[] to = new int[]{android.R.id.text1};

    // create simple cursor adapter
    SimpleCursorAdapter spadapter =
      new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, sp_curs, from, to );
    spadapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );

    //stopManagingCursor(sp_curs);
    //Chiudo il db perchè ho finito di riempire la mia list view
    sdb.close();

    spadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnercategory.setAdapter(spadapter);

    viewDialog.setContentView(dialogView);
    viewDialog.show();

    spinnercategory.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View arg1,
                int arg2, long arg3) {
            new_categoria = parent.getSelectedItem().toString();
            listdb.update("7", "Category", new_categoria, "2");
            c.requery();
        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

这是我的微调器xml

<?xml version="1.0" encoding="utf-8"?>  

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:paddingLeft="10dip"
>

<Spinner 
android:id="@+id/spinQ" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
/> 


</LinearLayout>

1 个答案:

答案 0 :(得分:0)

我要走出困境并建议您在某处附近有一个无效的数据库查询语句&#34; listdb.update()&#34;。

编辑:一些快速搜索表明它也可能与this或更可能this(不正确关闭游标或数据库)有关。