1

我的微调器有问题吗??我的应用程序没有崩溃,但出现了无法打开的 toast DB。所以我的微调器人口一定有问题..有人可以帮忙找出错误吗?谢谢!

// Open the DB, query all subject codes and refresh the listview
// when app resumes
   @Override
   protected void onResume() {
    super.onResume();

   ArrayList<String> menu = new ArrayList<String>();
    Spinner SpinMenu = (Spinner)this.findViewById(R.id.spinner1);
    SpinMenu.setAdapter(new ArrayAdapter<String>(this, 
        android.R.layout.simple_spinner_dropdown_item , menu));

    // Open/create the DB
    try {
        dbopener.createDatabase(); // Create DB if necessary
      dbopener.openDatabase(); // Open the DB

      Cursor menus = dbopener.getFood();
      while (menus.moveToNext()) {
         menu.add(menus.getString(0)); // Get the current subj
                                                  // code, add to list
      }
      menus.close();

      // Update the listview
      ArrayAdapter<String> ad = 
            (ArrayAdapter<String>)SpinMenu.getAdapter();
      ad.notifyDataSetChanged();

     SpinMenu.setOnItemSelectedListener(this);
    } catch (Exception e) {
        Toast.makeText(this, "Could not open DB", 
            Toast.LENGTH_LONG).show();
    }
}
4

0 回答 0