I’m trying to create a listview within a customdialog.
listview contains a custom row that is holding 4 textviews.
i’m a bit stuck as there are no error messages, but nothing shows and adapter seems to be empty (but fillmaps has data) – what am i missing?
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;
}
thanks for reading
If ListView within customDialog use:
instead