The problem is your onCreateView method.
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_complaints, container, false); //i added recipient = (EditText) v.findViewById(R.id.recipient); [...] return v; }
See the difference? You must call findViewById on the actual View object in the case of Fragments .
And the problem with Toast is that you are passing the worng object as the first parameter. You need Context , and you pass Fragment . Fragment not Context , but, fortunately, for you, Activity so, you should build your Toast as follows:
Toast.makeText(ComplaintsFragment.this.getActivity(), "No email client installed.", Toast.LENGTH_LONG).show();
Note that the call to getActivity() .
source share