2012-04-04 26 views
0

問題があります。 私のアクティビティにはボタンがあり、クリックするとメソッドが呼び出されます。このメソッドは、私にlistviewの警告ダイアログを表示し、アイテムのクリックを変数に保存したいのですが、メソッドを閉じたいが閉じない! なぜですか? メソッドのコードを掲載します。 私のlogcatは私に誤りを与えません。 誰も私を助けることができますか?メソッドが終了しない

private void getValuta() { 

    // AlertDialog creation 
    AlertDialog.Builder miaAlert = new AlertDialog.Builder(this); 

    final ListView lV = new ListView(this); 

    Cursor c = null; 


    // Set the title of the dialogBox 
    miaAlert.setTitle("Choose Valuta"); 

    // I call the Query 
    c = vdb.fetchValuteListView("0"); 

    // handle of the cursor 
    startManagingCursor(c); 

    // I create the SimpleCursorAdapter 
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, // Context 
      android.R.layout.simple_list_item_1, // row/product layout 
      c, // the cursor 
      new String[] { 
        ValuteDb.ValuteMetaData.VALUTE_NAME_KEY}, 
                     // the colums 
      new int[] { android.R.id.text1});// views 

    stopManagingCursor(c); 

    // The listView is filled using the adapter created above 
    lV.setAdapter(adapter); 

    miaAlert.setView(lV); 

    miaAlert.setCancelable(false); 

    // list view listener 
    lV.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View v, 
       int position, long id) { 

      String riga = String.valueOf(id); 
      String confr = vdb.getRecord(riga,2); 
      System.out.println("position= " + position + "/id= " + id+"/nome= "+confr); 
      new_valuta = vdb.getRecord(riga,2); 
      listdb.update("9", "Valuta", new_valuta, "2"); 
      c_list.requery(); 

      return; 

     } 
    }); 

    // I create the AlertDialog 
    AlertDialog alert = miaAlert.create(); 

    // I showw the AlertDialog 
    alert.show(); 
+0

あなたはより良い/より多くの答えを得るために英語にコメント、文字列、およびメソッドを翻訳したい場合があります。 –

答えて

0

はこれを試してください:

private void getValuta() { 

    // Creo l'alert Dialog 
    AlertDialog.Builder miaAlert = new AlertDialog.Builder(this); 

    final ListView lV = new ListView(this); 

    Cursor c = null; 


    // Setto il titolo del mio alert 
    miaAlert.setTitle("Choose Valuta"); 

    // Chiamo la Query che in questo caso è un all 
    c = vdb.fetchValuteListView("0"); 

    // Comincio a fare il management del cursore 
    startManagingCursor(c); 

    // Semplice cursor adapter 
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, // Contesto 
      android.R.layout.simple_list_item_1, // il layout di ogni riga/prodotto 
      c, // Il cursore 
      new String[] { 
        ValuteDb.ValuteMetaData.VALUTE_NAME_KEY},// questi 
                     // colonne 
      new int[] { android.R.id.text1});// in 
                    // queste 
                    // views 

    stopManagingCursor(c); 

    // Ora la list view si prende questo adapter appena creato sopra 
    lV.setAdapter(adapter); 

    miaAlert.setView(lV); 

    miaAlert.setCancelable(false); 

    // Listener della list view 
    lV.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View v, 
       int position, long id) { 


      AlertDialog alert = miaAlert.create(); 
      alert.show(); 

      String riga = String.valueOf(id); 
      String confr = vdb.getRecord(riga,2); 
      System.out.println("position= " + position + "/id= " + id+"/nome= "+confr); 
      new_valuta = vdb.getRecord(riga,2); 
      listdb.update("9", "Valuta", new_valuta, "2"); 
      c_list.requery(); 

      alert.dismiss(); 

      return; 

     } 
    }); 
関連する問題