gpt4 book ai didi

android - 在 Fragment 中创建 AlarmDialog

转载 作者:行者123 更新时间:2023-11-29 16:06:04 24 4
gpt4 key购买 nike

所以我在 fragment 中创建对话框时遇到错误

代码如下:

     public Dialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt("title");

return new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.logo)
.setTitle(R.string.groupDetails_rename)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
((GroupDetailsFragment) getSupportFragmentManager())
.doPositiveClick();
}
}).create();
}

我在 ((GroupDetailsFragment) getSupportFragmentManager()) 上有错误我应该写什么来代替 getSupportFragmentManager()

最佳答案

GroupDetailsFragment f = (GroupDetailsFragment) getSupportFragmentManager().findFragmentByTag("tag");

f.doPositiveClick();

“标签”将在您调用“show()”时传递

getSupportFragmentManager->v4getFragmentManager->native

关于android - 在 Fragment 中创建 AlarmDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18251966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com