android studio与AppCompactActvity中的片段发生冲突

时间:2018-09-08 11:51:15

标签: java android

当我尝试将AppCompactActivity类扩展到片段menu1.java时出现错误,该片段menu {.1}与应用程序中的FragmentManager发生冲突。活动

  

下面是我的名为menu1.java的片段,我想放置一个Java代码   对于该片段显示在应用程序中的布局,我可以将其放置在哪里。

FragmentManager
  

下面是我想放在其中的代码或功能   片段

   package com.sugerpot.yeshbizzle.maaio;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class menu1 extends Fragment{





    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //returning our layout file
        //change R.layout.yourlayoutfilename for each of your fragments
        return inflater.inflate(R.layout.fragment_menu_1, container, false);
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //you can set the title for your toolbar here for different fragments different titles
        getActivity().setTitle("Contact");
    }

}

0 个答案:

没有答案