当我尝试将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");
}
}