Use view.getContext rather of getActivity that could be null.