从对话框中调用片段方法
Invoke fragment method from dialog
有没有办法从它创建的片段中调用 MyDialog extends Dialog
中的方法?所以我可以使用 Context 但不知道如何使用。
该示例是选择打开相机、图库等的对话框
是的,您可以为此目的在对话框中使用界面。您将在 http://developer.android.com/guide/topics/ui/dialogs.html 中找到示例(您将在 "Passing Events Back to the Dialog's Host" 中找到示例)。
很简单,每次打开对话框都用TAG来标记:
DialogFragment.show(FragmentManager fm, String tag);
dialogFragment.show(getFragmentManager(), "MY_DIALOG");
然后调用它来检索它:
MyDiagFrag diagFrag = (MyDiagFrag)getFragmentManager()
.findFragmentByTag("MY_DIALOG")
有没有办法从它创建的片段中调用 MyDialog extends Dialog
中的方法?所以我可以使用 Context 但不知道如何使用。
该示例是选择打开相机、图库等的对话框
是的,您可以为此目的在对话框中使用界面。您将在 http://developer.android.com/guide/topics/ui/dialogs.html 中找到示例(您将在 "Passing Events Back to the Dialog's Host" 中找到示例)。
很简单,每次打开对话框都用TAG来标记:
DialogFragment.show(FragmentManager fm, String tag);
dialogFragment.show(getFragmentManager(), "MY_DIALOG");
然后调用它来检索它:
MyDiagFrag diagFrag = (MyDiagFrag)getFragmentManager()
.findFragmentByTag("MY_DIALOG")