package safeluck.drive.evaluation.customview;
|
|
import android.app.Dialog;
|
import android.content.DialogInterface;
|
import android.os.Bundle;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
import androidx.annotation.Nullable;
|
import androidx.appcompat.app.AlertDialog;
|
import androidx.fragment.app.DialogFragment;
|
|
public class MyDialogFragment extends DialogFragment {
|
@Nullable
|
@Override
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
return super.onCreateView(inflater, container, savedInstanceState);
|
}
|
|
@NonNull
|
@Override
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
.setTitle("请选择考试项")
|
.setMessage("来选择你要实现的一个愿望把")
|
.setPositiveButton("场考", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
if (callback != null){
|
callback.changKao();
|
}
|
}
|
})
|
.setNegativeButton("路考", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
if (callback!= null){
|
callback.luKao();
|
}
|
}
|
}).create();
|
dialog.setCancelable(false);
|
return dialog;
|
}
|
private Callback callback;
|
|
|
public interface Callback{
|
void changKao();
|
void luKao();
|
}
|
|
|
public void setCallback(Callback callback) {
|
this.callback = callback;
|
}
|
}
|