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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations