Android имеет диалог INT расширяет класс с ListFragment

Я имею ReceiveListFragment класс расширяется ListFragment и я хочу иметь Dialog но я получаю ошибку и не могу решить проблему.

public static class CDialog extends DialogFragment {
        public AddNoteDialogFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            getDialog().setTitle(getString(R.string.app_name));
            View view = inflater.inflate(R.layout.vdialog,
                    container);
            return view;
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            Dialog dialog = super.onCreateDialog(savedInstanceState);
            dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
            return dialog;
        }
    }

ОБНОВЛЕНИЕ ПОСТ 1:

use this class:
Error:(196, 15) java: no suitable method found for show(android.support.v4.app.FragmentManager,java.lang.String)
    method android.app.DialogFragment.show(android.app.FragmentTransaction,java.lang.String) is not applicable
      (actual argument android.support.v4.app.FragmentManager cannot be converted to android.app.FragmentTransaction by method invocation conversion)
    method android.app.DialogFragment.show(android.app.FragmentManager,java.lang.String) is not applicable
      (actual argument android.support.v4.app.FragmentManager cannot be converted to android.app.FragmentManager by method invocation conversion)

Скриншот:введите описание изображения здесь

ОБНОВЛЕНИЕ ПОСТ 2: И для этой функции ниже я получаю эту ошибку:

FATAL EXCEPTION: main
    android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Функция:

public Boolean eDialog(){
        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which){
                    case DialogInterface.BUTTON_POSITIVE:
                        android.os.Process.killProcess(android.os.Process.myPid());
                        System.exit(1);
                        break;

                    case DialogInterface.BUTTON_NEGATIVE:
                        break;
                }
            }
        };
        AlertDialog.Builder builder = new AlertDialog.Builder(G.context);

        builder.setMessage("Are you Exit?").setPositiveButton("yes", dialogClickListener)
                .setNegativeButton("no", dialogClickListener).show();

        return true;
    }

1 ответ

public class DFragment extends DialogFragment {
    //...
};

public class AccidentDetailsActivity extends ActionBarActivity {
    //...
    android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
    DFragment dialog = DFragment.newInstance("Test");
    dialog.show(fm, "ss");
Другие вопросы по тегам