Search in sources :

Example 1 with MainFragment

use of co.mobiwise.sample.fragment.MainFragment in project MaterialIntroView by iammert.

the class ToolbarMenuItemActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    switch(item.getItemId()) {
        case R.id.nav_demo:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
            break;
        case R.id.nav_gravity:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new GravityFragment()).commit();
            break;
        case R.id.nav_focus:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new FocusFragment()).commit();
            break;
        case R.id.nav_recyclerview:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new RecyclerviewFragment()).commit();
            break;
        case R.id.nav_toolbar:
            startActivity(new Intent(getApplicationContext(), ToolbarMenuItemActivity.class));
            break;
        case R.id.nav_tab:
            break;
        default:
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : MainFragment(co.mobiwise.sample.fragment.MainFragment) RecyclerviewFragment(co.mobiwise.sample.fragment.RecyclerviewFragment) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout) GravityFragment(co.mobiwise.sample.fragment.GravityFragment) FocusFragment(co.mobiwise.sample.fragment.FocusFragment)

Example 2 with MainFragment

use of co.mobiwise.sample.fragment.MainFragment in project MaterialIntroView by iammert.

the class MainActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    switch(item.getItemId()) {
        case R.id.nav_demo:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
            break;
        case R.id.nav_gravity:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new GravityFragment()).commit();
            break;
        case R.id.nav_focus:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new FocusFragment()).commit();
            break;
        case R.id.nav_recyclerview:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new RecyclerviewFragment()).commit();
            break;
        case R.id.nav_toolbar:
            startActivity(new Intent(getApplicationContext(), ToolbarMenuItemActivity.class));
            break;
        case R.id.nav_tab:
            break;
        default:
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : MainFragment(co.mobiwise.sample.fragment.MainFragment) RecyclerviewFragment(co.mobiwise.sample.fragment.RecyclerviewFragment) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout) GravityFragment(co.mobiwise.sample.fragment.GravityFragment) FocusFragment(co.mobiwise.sample.fragment.FocusFragment)

Example 3 with MainFragment

use of co.mobiwise.sample.fragment.MainFragment in project MaterialIntroView by iammert.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (savedInstanceState == null)
        getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : MainFragment(co.mobiwise.sample.fragment.MainFragment) NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)3 MainFragment (co.mobiwise.sample.fragment.MainFragment)3 Intent (android.content.Intent)2 FocusFragment (co.mobiwise.sample.fragment.FocusFragment)2 GravityFragment (co.mobiwise.sample.fragment.GravityFragment)2 RecyclerviewFragment (co.mobiwise.sample.fragment.RecyclerviewFragment)2 NavigationView (android.support.design.widget.NavigationView)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Toolbar (android.support.v7.widget.Toolbar)1