问题描述
在我的应用程序中,我想等待对话框动画完成后再执行某些操作,我该如何实现?
到目前为止,我已经通过使用postDelayed Handler设法达到了预期的效果,但是我觉得有更好的方法可以做到这一点:
当前代码:
private void ShowDialog()
{
final Dialog dialog = new Dialog(Objects.requireNonNull(getActivity()));
dialog.setContentView(R.layout.haircut_dialog);
Objects.requireNonNull(dialog.getwindow()).setBackgroundDrawableResource(android.R.color.transparent);
Window window = dialog.getwindow();
window.setGravity(Gravity.CENTER);
window.getAttributes().windowAnimations = R.style.DialogAnimation;
Button selectButton = dialog.findViewById(R.id.selectButton);
selectButton.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
final int SPLASH_TIME_OUT = 600;
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
Bundle bundle = new Bundle();
bundle.putString("haircutKey",haircutKey);
BeardCutSelectionFragment beardCutSelectionFragment = new BeardCutSelectionFragment();
beardCutSelectionFragment.setArguments(bundle);
FragmentManager manager = Objects.requireNonNull(getActivity()).getSupportFragmentManager();
manager.beginTransaction().replace(R.id.innerFragmentContainer,beardCutSelectionFragment)
.addToBackStack(null)
.commit();
}
},SPLASH_TIME_OUT);
}
});
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(false);
window.setLayout(ActionBar.LayoutParams.WRAP_CONTENT,ActionBar.LayoutParams.WRAP_CONTENT);
dialog.show();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)