simpleadapter кажется пустым - почему? - PullRequest
1 голос
/ 21 марта 2012

Я пытаюсь создать просмотр списка в настраиваемом диалоге.listview содержит пользовательскую строку, содержащую 4 текстовых просмотра.Я немного застрял, так как нет сообщений об ошибках, но ничего не отображается, и адаптер кажется пустым (но у fillmaps есть данные) - чего мне не хватает?

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;
}

спасибо за чтение

1 Ответ

0 голосов
/ 21 марта 2012

Если ListView в customDialog использовать:

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

вместо

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