【问题标题】:spinner in dialog with invalid statement in fillwindow()对话框中的微调器,fillwindow() 中的语句无效
【发布时间】:2012-04-17 08:05:24
【问题描述】:

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

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>

【问题讨论】:

  • 第一次创建activity时是否抛出错误?或者当您导航到其他地方并返回时?

标签: android android-alertdialog android-spinner


【解决方案1】:

我会不顾一切地建议您在“listdb.update()”附近的某处有一个无效的数据库查询语句。

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

【讨论】:

  • 谢谢,但不存在问题。我说我的微调器可以工作,但它看起来全是白色的。它不从我的数据库中获取参数。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-22
  • 2011-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-16
相关资源
最近更新 更多