Przepisuję swoją aplikację z obsługą Fragments API
. W pierwotnym wniosku Mam AlertDialog
który jest tworzony tak:DialogFragment: Używanie AlertDialog z niestandardowym układem
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.button_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
ListView mListView = (ListView) view.findViewById(R.id.mblist);
builder.setTitle(getString(R.string.sysinfo)).setNeutralButton(
getString(R.string.okay), null);
Cursor dcursor = propManager.propCursor();
if (dcursor.moveToFirst()) {
startManagingCursor(dcursor);
String[] from = { Constants.NAME_DET,
Constants.VALUE_DET };
int[] to = { R.id.mbname, R.id.mbvalue };
SimpleCursorAdapter dadapter = new SimpleCursorAdapter(this,
R.layout.info_list_row, dcursor, from, to);
mListView.setAdapter(dadapter);
}
final Dialog dialog = builder.create();
dialog.show();
Jak mogę wyświetlać ten sam dialog poprzez DialogFragment? Przeczytałem dokumentację, ale mam problem z ustaleniem, jak to zrobić.
To bardzo pomogło. Dzięki. – BruceHill
Wolałbyś 'getActivity(). GetLayoutInflater()' zamiast wywoływać usługę systemową i rzutowanie? –
Niesamowita odpowiedź. Na wszelki wypadek, jeśli ktoś jest ciekawy, [dokumentacja to omawia] (https://developer.android.com/reference/android/app/DialogFragment.html). – Project