这是代码:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mview= inflater.inflate(R.layout.fragment_noification, container, false);
SOP=Shared.getInstance().getsop(getActivity());
recyclerView = (RecyclerView) mview.findViewById(R.id.recyclerview);
data_list = new ArrayList<>();
arsa= mview.findViewById( R.id.ars);
// mSwipeRefreshLayout = (SwipeRefreshLayout) mview.findViewById(R.id.swiperefresh);
// mSwipeRefreshLayout.setOnRefreshListener((SwipeRefreshLayout.OnRefreshListener) mview);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
adapter = new CustomAdapter(getActivity(), (ArrayList<MyData>) data_list);
recyclerView.setAdapter(adapter);
img = (ImageView) mview.findViewById(R.id.noinfo);
txt1 = (TextView) mview.findViewById(R.id.networkerror);
Toolbar toolbar = (Toolbar) mview.findViewById(R.id.toolbar);
cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
activeNetwork = cm.getActiveNetworkInfo();
arsa.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"Success",Toast.LENGTH_LONG).show();
}
});
答案 0 :(得分:0)
你不应该在RecyclerView中使用片段,它不支持片段,有关更多信息,你可以阅读answer
答案 1 :(得分:0)
由于您的context
null
更改此
Toast.makeText(context,"Success",Toast.LENGTH_LONG).show();
要
Toast.makeText(getActivity(),"Success",Toast.LENGTH_LONG).show();