0

Here is code:

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();
        }
    });
Munir
  • 2,548
  • 1
  • 11
  • 20

2 Answers2

0

you shouldn´t use fragments in a RecyclerView, it isn´t support Fragments, for more information you can read this answer

JJaviMS
  • 392
  • 6
  • 18
0

It's due to your context null

Change this

 Toast.makeText(context,"Success",Toast.LENGTH_LONG).show();

To

Toast.makeText(getActivity(),"Success",Toast.LENGTH_LONG).show();
Munir
  • 2,548
  • 1
  • 11
  • 20