其他分享
首页 > 其他分享> > DialogFragment 对话框 碎片

DialogFragment 对话框 碎片

作者:互联网


package com.example.m_evolution; import android.app.Dialog; import android.app.DialogFragment; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.view.View; import android.view.WindowManager; import android.widget.SeekBar; import android.widget.TextView; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; import com.melnykov.fab.FloatingActionButton; public class ReplayRecordDialogFragment extends DialogFragment { public static ReplayRecordDialogFragment newInstance(String file_name) { ReplayRecordDialogFragment dialogFragment = new ReplayRecordDialogFragment(); Bundle bundle = new Bundle(); bundle.putString(FILE_NAME, file_name); dialogFragment.setArguments(bundle); return dialogFragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { file_name = getArguments().getString(FILE_NAME); } } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_replayrecord, null); builder.setView(view); return builder.create(); } }

使用起来与Fragment很相像

在Activity使用时:

ReplayRecordDialogFragment fragmentReplay = ReplayRecordDialogFragment.newInstance(filename_record);
fragmentReplay.show(getFragmentManager(), ReplayRecordDialogFragment.class.getSimpleName());

 

标签:对话框,Bundle,碎片,ReplayRecordDialogFragment,import,android,public,DialogFragment,vi
来源: https://www.cnblogs.com/zhaozilongcjiajia/p/10689512.html