-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeFragment.java
54 lines (42 loc) · 1.8 KB
/
HomeFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.foodapp.food.recipe.fragment;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.foodapp.food.recipe.R;
public class HomeFragment extends Fragment
{
public HomeFragment()
{
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
final View view = inflater.inflate(R.layout.fragment_home, container, false); // sets layout of home activity
//for the magnifying glass search icon
FloatingActionButton fab = view.findViewById(R.id.fab); //fragment_home.xml
fab.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
//Check search recipes menu on the slide menu
NavigationView navigationView = getActivity().findViewById(R.id.nav_view); // from activity_main.xml
navigationView.setCheckedItem(R.id.nav_search);
FragmentManager manager = getActivity().getSupportFragmentManager();
SearchFragment searchFragment = new SearchFragment(); // jumps to searchFragment for search operations
manager.beginTransaction().replace(R.id.root_layout, searchFragment, searchFragment.getTag()).addToBackStack( null ).commit();
}
});
return view;
}
}