我想簡單地調用從活動的對話片段點擊一個按鈕後調用DialogFragment:如何從活動
eventInviteDecline.setOnClickListener(new View.OnClickListener() {
EventInviteResponseConfirmDialog newRespond = new EventInviteResponseConfirmDialog();
FragmentManager fm = getActivity().getFragmentManager();
public void onClick(View arg0) {
Bundle args = new Bundle();
args.putString("response", "decline");
newRespond.setArguments(args);
newRespond.show(fm, "ok");
}
});
然而,在代碼中,它調用的錯誤,指出:Cannot resolve method getActivity()
。
我該如何得到這個工作?