override depricated method in android.support.v4.app.fragment : 
        @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            activitycomander = (TopSectionListener) activity;
        }catch (ClassCastException e){
            throw new ClassCastException(activity.toString());
        }
    }
this is the code of my java class linkig with MainActivity.
there is issue with onattach method in android studio.. it shows as overline. and shows the message: onattach (android.app.activity) is deprecated:

     public void createMeme(String top, String bottom){
        bottomsection fragmentbottom = (bottomsection) getSupportFragmentManager().findFragmentById(R.id.fragment2);
        fragmentbottom.setMemeText(top, bottom);
    }

Above mentioned is mainactivity code in which topsection and bottomsection are the names of my java classes and its continuosly red and shows: connot reslove method

i have done Clean project, rebuild project and checked the options to add or remove the imports automaticlly
