フラグメント内にDialogFragmentを表示しようとしましたが、成功しませんでした。ここに私のコード:それの断片が画面に表示されているときはいつでもフラグメント内にDialogFragmentを表示
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume");
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null && !user.isEmailVerified()) {
InfoDialogFragment dialog = new InfoDialogFragment();
dialog.show(getActivity().getSupportFragmentManager(), "InfoDialogFragment");
}
}
は、画面が暗くなると、私は、画面をタッチすると、それは通常、コントラストを取り戻すが、私は、ダイアログの断片を見ることはできません。 私は何が欠けていますか?ここ
はDialogFragmentためのコードである:
public class InfoDialogFragment extends DialogFragment {
private InfoDialogListener listener;
@Override
public void onAttach(Context activity) {
super.onAttach(activity);
// Verify that the host activity implements the callback interface
try {
// Instantiate the InfoDialogListener so we can send events to the host
listener = (InfoDialogListener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
+ " must implement DeleteListListener");
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
View layout = inflater.inflate(R.layout.fragment_info, null);
TextView message = (TextView) layout.findViewById(R.id.message);
message.setText(getActivity().getString(R.string.user_not_verified));
//
Button ok = (Button) layout.findViewById(R.id.ok_button);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onDialogOKClick(InfoDialogFragment.this);
}
});
return builder.create();
}
public interface InfoDialogListener {
void onDialogOKClick(DialogFragment dialog);
}
}
おかげ
- FragmentInteractionListenerパターングーグルを使いますボイラープレートの断片/活動コードに入れます。 –
InfoDialogFragment code hereを入力してください –
InfoDialogFragmentコードを表示できますか? – Gudin