I am getting the following error
Attempt to invoke virtual method \'void android.widget.StackView.setAdapter(android.widget.Adapter)\' on a null
You are doing:
stackView = (StackView) getActivity().findViewById(R.id.stackView1);
Your stackView is null. getActivity().findViewById returns null.
Why are you using getActivity()?
Where is the stackView? You should load it from the right xml.
as @Tauqir mentioned, you need to inflate the right xml like this:
View view = inflater.inflate(R.layout.events_layout, null);
stackView = (StackView) view.findViewById(R.id.stackView1);
return view;