title: Convert Activity into Fragment
body: <p>I made a navigation in my project, than I have activities, I would made menu from those activities into navigation. so I need to convert those activities into fragments.</p>
  
  <p>This my first activity.java</p>
  
  <pre><code>public class ToDoList extends AppCompatActivity implements BatListener, OnItemClickListener, OnOutsideClickedListener {
  
      private BatRecyclerView mRecyclerView;
      private BatAdapter mAdapter;
      private List&lt;BatModel&gt; mGoals;
      private BatItemAnimator mAnimator;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.to_do_list);
  
          // Navigator
          FoldingTabBar tabBar = (FoldingTabBar) findViewById(R.id.folding_tab_bar);
  
          tabBar.setOnFoldingItemClickListener(new FoldingTabBar.OnFoldingItemSelectedListener() {
              @Override
              public boolean onFoldingItemSelected(@NotNull MenuItem item) {
                  switch (item.getItemId()) {
                      case R.id.menu_profile:
                          Intent intent0 = new Intent(ToDoList.this, Home.class);
                          startActivity(intent0);
                          break;
                      case R.id.menu_todo:
                          break;
                      case R.id.menu_schedule:
                          Intent intent1 = new Intent(ToDoList.this, TimeTable.class);
                          startActivity(intent1);
                          break;
                      case R.id.menu_settings:
                          break;
                  }
                  return false;
              }
          });
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setTitle("");
  
          ((TextView) findViewById(R.id.text_title)).setTypeface(TypefaceUtil.getAvenirTypeface(this));
  
          mRecyclerView = (BatRecyclerView) findViewById(R.id.bat_recycler_view);
          mAnimator = new BatItemAnimator();
  
          mRecyclerView.getView().setLayoutManager(new LinearLayoutManager(this));
          mRecyclerView.getView().setAdapter(mAdapter = new BatAdapter(mGoals = new ArrayList&lt;BatModel&gt;() {{
  
          }}, this, mAnimator).setOnItemClickListener(this).setOnOutsideClickListener(this));
  
          ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new BatCallback(this));
          itemTouchHelper.attachToRecyclerView(mRecyclerView.getView());
          mRecyclerView.getView().setItemAnimator(mAnimator);
          mRecyclerView.setAddItemListener(this);
  
          findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  mRecyclerView.revertAnimation();
              }
          });
  
      }
  
      @Override
      public void add(String string) {
          mGoals.add(0, new Goal(string));
          mAdapter.notify(AnimationType.ADD, 0);
      }
  
      @Override
      public void delete(int position) {
          mGoals.remove(position);
          mAdapter.notify(AnimationType.REMOVE, position);
      }
  
      @Override
      public void move(int from, int to) {
          if (from &gt;= 0 &amp;&amp; to &gt;= 0) {
              mAnimator.setPosition(to);
              BatModel model = mGoals.get(from);
              mGoals.remove(model);
              mGoals.add(to, model);
              mAdapter.notify(AnimationType.MOVE, from, to);
  
              if (from == 0 || to == 0) {
                  mRecyclerView.getView().scrollToPosition(Math.min(from, to));
              }
          }
      }
  
      @Override
      public void onClick(BatModel item, int position) {
          Toast.makeText(this, item.getText(), Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onOutsideClicked() {
          mRecyclerView.revertAnimation();
      }
  
  }
  </code></pre>
  
  <p>I tried to use this code, from Mr Abhi instruction, I just edited a little bit for removing the toolbar, and some I solved.</p>
  
  <p>This is my fragment.java</p>
  
  <pre><code>public class ToDoListFragment extends Fragment implements BatListener, OnItemClickListener, OnOutsideClickedListener {
  
  private BatRecyclerView mRecyclerView;
  private BatAdapter mAdapter;
  private List&lt;BatModel&gt; mGoals;
  private BatItemAnimator mAnimator;
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View root = inflater.inflate(R.layout.todo_list_fragment, null);
      return root;
  }
  
  public void onViewCreated(View view, Bundle savedInstanceState) {
      // you can add listener of elements here
    /*Button mButton = (Button) view.findViewById(R.id.button);
      mButton.setOnClickListener(this); */
  
      ((TextView) view.findViewById(R.id.tdl_date)).setTypeface(TypefaceUtil.getAvenirTypeface(getActivity()));
  
      mRecyclerView = (BatRecyclerView) view.findViewById(R.id.tdl_bat_recyclerView);
      mAnimator = new BatItemAnimator();
  
      mRecyclerView.getView().setLayoutManager(new LinearLayoutManager(getActivity()));
      mRecyclerView.getView().setAdapter(mAdapter = new BatAdapter(mGoals = new ArrayList&lt;BatModel&gt;() {{
  
      }}, this, mAnimator).setOnItemClickListener(this).setOnOutsideClickListener(this));
  
      ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new BatCallback(this));
      itemTouchHelper.attachToRecyclerView(mRecyclerView.getView());
      mRecyclerView.getView().setItemAnimator(mAnimator);
      mRecyclerView.setAddItemListener(this);
  
      view.findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              mRecyclerView.revertAnimation();
          }
      });
  
  }
  
  @Override
  public void add(String string) {
      mGoals.add(0, new Goal(string));
      mAdapter.notify(AnimationType.ADD, 0);
  }
  
  @Override
  public void delete(int position) {
      mGoals.remove(position);
      mAdapter.notify(AnimationType.REMOVE, position);
  }
  
  @Override
  public void move(int from, int to) {
      if (from &gt;= 0 &amp;&amp; to &gt;= 0) {
          mAnimator.setPosition(to);
          BatModel model = mGoals.get(from);
          mGoals.remove(model);
          mGoals.add(to, model);
          mAdapter.notify(AnimationType.MOVE, from, to);
  
          if (from == 0 || to == 0) {
              mRecyclerView.getView().scrollToPosition(Math.min(from, to));
          }
      }
  }
  
  @Override
  public void onClick(BatModel item, int position) {
      Toast.makeText(getActivity(), item.getText(), Toast.LENGTH_SHORT).show();
  }
  
  @Override
  public void onOutsideClicked() {
      mRecyclerView.revertAnimation();
  }
  </code></pre>
  
  <p>But it crushed when I started the app. the log showed that  No view found for id 0x7f09004c (package:id/container) for fragment.</p>
  
  <p>I hope you guys could help me as you teach me. Thanks for the second time.</p>