Search in sources :

Example 36 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project AdMoney by ErnestoGonAr.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    bd = new BDHandlerAM(this);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    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 : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 37 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project AdMoney by ErnestoGonAr.

the class MainActivity method onNavigationItemSelected.

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    if (id == R.id.nav_ingresos) {
        Intent i = new Intent(MainActivity.this, Reporte_Ingresos.class);
        startActivity(i);
    } else if (id == R.id.nav_egresos) {
        Intent i = new Intent(MainActivity.this, Reporte_Egresos.class);
        startActivity(i);
    } else if (id == R.id.nav_prestamos) {
        Intent i = new Intent(MainActivity.this, Reporte_Prestamos.class);
        startActivity(i);
    } else if (id == R.id.nav_adeudos) {
        Intent i = new Intent(MainActivity.this, Reporte_Adeudos.class);
        startActivity(i);
    } else if (id == R.id.nav_pagoR) {
        Intent i = new Intent(MainActivity.this, PagoRecurrenteActivity.class);
        startActivity(i);
    } else if (id == R.id.nav_reiniciar) {
        new AlertDialog.Builder(this).setMessage("Estás seguro que deseas reiniciar los registros de la aplicacion?\n" + "Se eliminaran todos los registros. Esta accion no puede ser revertida.").setCancelable(false).setPositiveButton("Si", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                try {
                    bd.eliminarRegistros();
                    Thread.sleep(500);
                    recreate();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).setNegativeButton("No", null).show();
    } else if (id == R.id.nav_seguridad) {
        Login log = bd.obtenerLogin();
        if (log == null) {
            Intent i = new Intent(MainActivity.this, EstablecerActivity.class);
            startActivity(i);
        } else {
            Intent i = new Intent(MainActivity.this, ConfirmarActivity.class);
            startActivity(i);
        }
    } else if (id == R.id.nav_singresos) {
        Intent i = new Intent(MainActivity.this, CategoriasIngreso.class);
        startActivity(i);
    } else if (id == R.id.nav_segresos) {
        Intent i = new Intent(MainActivity.this, CategoriasEgresos.class);
        startActivity(i);
    } else if (id == R.id.nav_share) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, "AdMoney");
        intent.putExtra(Intent.EXTRA_TEXT, "¿Quieres administrar mejor tu dinero?\n Descarga AdMoney https://play.google.com/store/apps/details?id=com.ernesto.admoney");
        startActivity(Intent.createChooser(intent, "Compartir con"));
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 38 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Android-PanesLibrary by cricklet.

the class PhoneDelegate method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    if (findViewById(R.id.content_frame) == null)
        setContentView(R.layout.phone_layout);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    drawerToggle = new ActionBarDrawerToggle(getActivity(), drawer, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
            supportInvalidateOptionsMenu();
        // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            supportInvalidateOptionsMenu();
        // creates call to onPrepareOptionsMenu()
        }
    };
    drawer.setDrawerListener(drawerToggle);
    FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View)

Example 39 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project android_frameworks_base by AOSPA.

the class DrawerController method create.

/**
     * Returns a controller suitable for {@code Layout}.
     */
static DrawerController create(Activity activity) {
    DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    if (layout == null) {
        return new DummyDrawerController();
    }
    View drawer = activity.findViewById(R.id.drawer_roots);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
    drawer.getLayoutParams().width = calculateDrawerWidth(activity);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
    return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Example 40 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Ushahidi_Android by ushahidi.

the class BaseActivity method initNavDrawer.

private void initNavDrawer() {
    navDrawerAdapter = new NavDrawerAdapter(this);
    listView.setOnItemClickListener(new NavDrawerItemClickListener());
    listView.setAdapter(navDrawerAdapter);
    if (drawerLayout != null) {
        drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
        // ActionBarDrawerToggle ties together the the proper interactions
        // between the sliding drawer and the action bar app icon
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.open, R.string.close) {

            public void onDrawerClosed(android.view.View view) {
                getSupportActionBar().setTitle(getTitle());
                super.onDrawerClosed(view);
            }

            public void onDrawerOpened(android.view.View drawerView) {
                getSupportActionBar().setTitle(getTitle());
                super.onDrawerOpened(drawerView);
            }
        };
    }
    drawerLayout.setDrawerListener(drawerToggle);
}
Also used : NavDrawerAdapter(com.ushahidi.android.app.adapters.NavDrawerAdapter) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)63 View (android.view.View)59 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 AdapterView (android.widget.AdapterView)22 NavigationView (android.support.design.widget.NavigationView)21 ListView (android.widget.ListView)21 Intent (android.content.Intent)19 Toolbar (android.support.v7.widget.Toolbar)19 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)12 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 SuppressLint (android.annotation.SuppressLint)5 TabLayout (android.support.design.widget.TabLayout)5 ArrayList (java.util.ArrayList)5 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4