2012-03-21 5 views
1

私はcustomdialog内でリストビューを作成しようとしています。 listviewには、4つのテキストビューを保持するカスタム行が含まれています。 エラーメッセージは表示されませんが、何も表示されず、アダプタが空であるようです(ただし、fillmapsにはデータがあります)。何が欠けていますか? customDialog内のリストビューを使用する場合はシンプルアダプターが空に見える - なぜですか?

答えて

0

を読み取るための

protected Dialog onCreateDialog(int id) { 
    switch (id) {   
      case JOURNEY_DIALOG_ID: 
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      final View layout = inflater.inflate(R.layout.journey_dialog, (ViewGroup) findViewById(R.id.root)); 

      AlertDialog.Builder journeyDialog = new AlertDialog.Builder(this); 
     journeyDialog.setView(layout); 
     // Configure the AlertDialog 
     journeyDialog.setTitle(myJourneyDetails.getString(JOURNEY_DETAILS_TITLE, "Journey")); 
     journeyDialog.setNegativeButton(R.string.go_back, new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int whichButton) { 
       JourneyResult.this.removeDialog(JOURNEY_DIALOG_ID); 
       onBackPressed(); 
      } 
     }); 
     journeyDialog.setMessage(journeyMessage); 

     String[] from = new String[] {"rowid", "segment length", "time1", "time2"}; 
     int[] to = new int[] { R.id.textView_LVRowID, R.id.textView_LVSegmentLength, R.id.textView_LVTime1, R.id.textView_LVTime2 }; 
     ListView timeList = (ListView) findViewById(R.id.listview_time_prediction); 
     // fill in the grid_item layout 
     try { 
      SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.listview_row, from, to); 
      timeList.setAdapter(adapter); 
      adapter.notifyDataSetChanged(); 
      timeList.invalidate(); 
     } catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

     return journeyDialog.create();  
    } 
    return null; 
} 

感謝:

... 
ListView timeList = (ListView) layout.findViewById(R.id.listview_time_prediction); 
... 

代わり

... 
ListView timeList = (ListView) findViewById(R.id.listview_time_prediction); 
... 
+0

感謝!私は今リストを見ることができます - 残念ながら、すべてのデータはまだありません(私は最初のtextviewを取得しているように見える)が、レイアウトを修正する作業:) – Sandra

関連する問題