Android studio Listview in Fragment : I want to create a ListView in Fragment but something goes wrong.
In layout listmygroups.xml are three TextViews (trainermygroupslistwhen, trainermygroupslistwhere, trainermygroupslistname). 
I try to open fragment with listview(TrainerMyGroups) from another fragment by:
 

    getFragmentManager().beginTransaction().replace(R.id.MainContainer,new TrainerMyGroups()).addToBackStack(null).commit();

TrainerMyGroups.java:

    package com.hgyghyfghyu.apkana40;
    
    
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ListView;
    
    
    /**
     * A simple {@link Fragment} subclass.
     */
    public class TrainerMyGroups extends Fragment {
    
    
        ListView listView;
        TrainerGroupsAdapter adapter;
        String when[]={"tak","ret","sd"};
        String where[]={"dsf","sdf","sdfsdf"};
        String name[]={"sdfsdf","xcvxcv","xcvxcv"};
    
        public TrainerMyGroups() {
            // Required empty public constructor
        }
    
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            return inflater.inflate(R.layout.fragment_trainer_my_groups, container, false);
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            listView = (ListView) getActivity().findViewById(R.id.trainermygroupslistview);
            adapter = new TrainerGroupsAdapter(getContext(),R.layout.list_mygroups);
            listView.setAdapter(adapter);
            for(int i=0;i<3;i++){
                TrainerGroupsDataProvider dataprovider = new TrainerGroupsDataProvider(when[i],name[i],where[i]);
                adapter.add(dataprovider);
    
            }
    
        }
    }

TrainerGroupsAdapter.java:

    package com.hgyghyfghyu.apkana40;
    
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.TextView;
    
    import java.util.List;
    import java.util.ArrayList;
    
    /**
     * Created by dd on 2016-04-04.
     */
    public class TrainerGroupsAdapter extends ArrayAdapter {
    
        List list = new ArrayList();
    
        public TrainerGroupsAdapter(Context context, int resource) {
            super(context, resource);
        }
    
        static class Datahandler{
            TextView name;
            TextView when;
            TextView where;
        }
    
        @Override
        public void add(Object object) {
            super.add(object);
            list.add(object);
        }
    
        @Override
        public int getCount() {
            return this.list.size();
        }
    
        @Override
        public Object getItem(int position) {
            return this.list.get(position);
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row;
            row=convertView;
            Datahandler handler;
            if(convertView==null){
                LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row= inflater.inflate(R.layout.list_mygroups,parent,false);
                handler = new Datahandler();
                handler.name =  (TextView) row.findViewById(R.id.trainermygroupslistname);
                handler.where =  (TextView) row.findViewById(R.id.trainermygroupslistwhere);
                handler.when =  (TextView) row.findViewById(R.id.trainermygroupslistwhen);
                row.setTag(handler);
            }
            else {
                handler = (Datahandler)row.getTag();
            }
    
            TrainerGroupsDataProvider dataProvider;
            dataProvider = (TrainerGroupsDataProvider)this.getItem(position);
            handler.name.setText(dataProvider.getName());
            handler.when.setText(dataProvider.getWhen());
            handler.where.setText(dataProvider.getWhere());
            return row;
        }
    
    
    }

and there is error from AndroidMonitor

    FATAL EXCEPTION: main
                                                                              Process: com.hgyghyfghyu.apkana40, PID: 27778
                                                                              java.lang.NullPointerException
                                                                                  at com.hgyghyfghyu.apkana40.TrainerMyGroups.onCreate(TrainerMyGroups.java:41)
                                                                                  at android.support.v4.app.Fragment.performCreate(Fragment.java:1951)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1029)
                                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
                                                                                  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                                                                                  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
                                                                                  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
                                                                                  at android.os.Handler.handleCallback(Handler.java:733)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:136)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5045)
                                                                                  at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                  at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                                  at dalvik.system.NativeStart.main(Native Method)



line 41 from TrainerMyGroups is

    listView.setAdapter(adapter);

I am not sure but probably this solution works only in Activity, not in Fragment, How can I change my code to make it workable?