2012-03-21 2 views
1

customdialog 내에서 listview를 만들려고합니다. listview에는 4 개의 텍스트 뷰를 보유하는 사용자 정의 행이 있습니다. 오류 메시지가 없으므로 조금 갇혀 있지만 어댑터가 비어있는 것 같습니다 (fillmaps에는 데이터가 있음) - 무엇이 없습니까? customDialog 내에서 ListView를 사용하는 경우simpleadapter는 비어있는 것 같습니다 - 왜?

답변

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

관련 문제