List of usage examples for android.support.v4.view GravityCompat START
int START
To view the source code for android.support.v4.view GravityCompat START.
Click Source Link
From source file:com.codemobiles.demo.authendemo.MainActivity.java
/** * Begin Part of making Slide Menu//from ww w . j ava 2 s . c om */ private void setupSlideMenu() { listView = (ListView) findViewById(R.id.drawerlistview); listView.setAdapter(new SlideMenuAdapter(this)); // App Icon getSupportActionBar().setDisplayHomeAsUpEnabled(true); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close); drawerLayout.setDrawerListener(actionBarDrawerToggle); drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Snackbar.make(view, String.format("Selected Menu #%d", position), Snackbar.LENGTH_LONG).show(); drawerLayout.closeDrawer(listView); } }); }
From source file:com.fjoglar.etsitnoticias.view.activities.BookmarksListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Open the navigation drawer when the home icon is selected from the toolbar. drawerLayout.openDrawer(GravityCompat.START); return true; case R.id.action_filter: drawerLayout.openDrawer(GravityCompat.END); return true; }//from w ww.ja v a2 s. c om return true; }
From source file:com.bfemmer.portdawgtoolkit.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override// w ww . j ava2 s .c o m public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); Fragment fragment = null; Class fragmentClass = null; if (id == R.id.nav_dashboard) { fragmentClass = DashboardFragment.class; } else if (id == R.id.nav_readiness) { Intent intent = new Intent(MainActivity.this, ReadinessActivity.class); startActivity(intent); return true; } else if (id == R.id.nav_safety) { fragmentClass = SafetyFragment.class; } else if (id == R.id.nav_tools) { fragmentClass = ToolsMenuFragment.class; } else if (id == R.id.nav_share) { //fragmentClass = DashboardFragment.class; } else if (id == R.id.nav_send) { //fragmentClass = ToolsMenuFragment.class; } try { fragment = (Fragment) fragmentClass.newInstance(); } catch (Exception e) { e.printStackTrace(); } FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.hannesdorfmann.mosby3.sample.mvi.MainActivity.java
private boolean closeDrawerIfOpen() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerLayout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); return true; }//from w w w.j av a 2s . c o m return false; }
From source file:com.byteshaft.licenseservice.ResultActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w w w . java 2 s. c om*/ ArrayList<String> dataList = getIntent().getStringArrayListExtra(AppGlobals.TOTAL_CATEGORIES); listView = (ListView) findViewById(R.id.result_list_view); HashMap<String, String> hashMap = (HashMap<String, String>) getIntent() .getSerializableExtra(AppGlobals.ANSWER_DATA); totalQuestions = getIntent().getIntExtra(AppGlobals.TOTAL_QUESTIONS, 0); Log.i("Total ques received", String.valueOf(totalQuestions)); for (String category : dataList) { if (hashMap.get(category) != null) { if (!category.equals(Data.sGeneralKnowledge) && !category.equals(Data.sTrafficSignsSection)) { totalTrue = totalTrue + Integer.parseInt(String.valueOf(hashMap.get(category))); } } } Log.i("HashMap", String.valueOf(hashMap)); Adapter adapter = new Adapter(getApplicationContext(), R.layout.layout_result_delegate, dataList, hashMap); listView.setAdapter(adapter); final 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); disableNavigationViewScrollbars(navigationView); header = navigationView.getHeaderView(0); generalAnswer = (TextView) header.findViewById(R.id.general_knowledge_answer); roadSafetyEssentials = (TextView) header.findViewById(R.id.road_safety_answer); trafficSigns = (TextView) header.findViewById(R.id.traffic_signs_answer); testStatus = (TextView) header.findViewById(R.id.test_status); roadSafetyEssentials.setText(String.valueOf(totalTrue) + "/" + "20"); String generalAnswers = String.valueOf(hashMap.get(Data.sGeneralKnowledge)); String trafficAnswers = String.valueOf(hashMap.get(Data.sTrafficSignsSection)); generalAnswer.setText(generalAnswers + "/" + "15"); if (Integer.valueOf(generalAnswers) < 12) { failInGeneral = true; generalAnswer.setTextColor(Color.RED); } else { generalAnswer.setTextColor(Color.parseColor("#009900")); } trafficSigns.setText(trafficAnswers + "/" + "10"); if (Integer.valueOf(trafficAnswers) < 10) { trafficSigns.setTextColor(Color.RED); } else { trafficSigns.setTextColor(Color.parseColor("#009900")); } if (totalTrue < 20) { roadSafetyEssentials.setTextColor(Color.RED); } else { roadSafetyEssentials.setTextColor(Color.parseColor("#009900")); } if (Integer.valueOf(trafficAnswers) < 10 || totalTrue < 20) { failInOverAll = true; } if (failInOverAll || failInGeneral) { testStatus.setText("Fail"); testStatus.setTextColor(Color.RED); } else { testStatus.setText("Pass"); testStatus.setTextColor(Color.parseColor("#009900")); } Calendar c = Calendar.getInstance(); System.out.println("Current time => " + c.getTime()); SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String formattedDate = df.format(c.getTime()); TextView date = (TextView) header.findViewById(R.id.date); date.setText(formattedDate); Button haveAnotherGo = (Button) header.findViewById(R.id.button); haveAnotherGo.setOnClickListener(this); drawer.openDrawer(GravityCompat.START); }
From source file:cn.jasonlv.siri.fragment.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. *//*from w w w.j a v a 2s .c o m*/ public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:com.example.administrator.winsoftsalesproject.activity.NavHomeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override// w ww. j a va 2s . co m public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { //Replacing the main content with ContentFragment Which is our Inbox View; case R.id.nav_item_home: fragmentTransaction(home); return true; // For rest of the options we just show a toast on click case R.id.nav_item_sale_list: Intent intent = new Intent(getApplicationContext(), HomeActivity.class); startActivity(intent); return true; case R.id.nav_item_sale_product: intent = new Intent(getApplicationContext(), SalesActivity.class); startActivity(intent); return true; case R.id.nav_item_customer_list: intent = new Intent(getApplicationContext(), CustomerActivity.class); startActivity(intent); return true; case R.id.nav_item_logout: logOutDialog(); return true; case R.id.nav_item_exit: exitDialog(); return true; default: DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } }
From source file:click.kobaken.rxirohaandroid_sample.view.activity.MainActivity.java
private void initToolbar() { binding.toolbar.setTitle(getString(R.string.receive)); binding.toolbar.setNavigationIcon(/*from w w w. j ava 2 s .c o m*/ ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_menu_white_24dp)); binding.toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { binding.drawerLayout.openDrawer(GravityCompat.START); } }); }
From source file:com.grandilo.stanthony.MainActivity.java
private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from www . j ava 2 s. co m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case android.R.id.home: mDrawerLayout.openDrawer(GravityCompat.START); return true; case R.id.nav_reminder: // A date-time specified in milliseconds since the epoch. long startMillis = 0; Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, startMillis); Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build()); startActivity(intent); return true; case R.id.nav_feedback: startActivity(new Intent(MainActivity.this, FeedBack.class)); return true; case R.id.nav_about: startActivity(new Intent(MainActivity.this, About.class)); return true; } return true; } }); }
From source file:com.example.admin.news.mvp.ui.activities.base.BaseActivity.java
private void setCheckedEvent(SwitchCompat dayNightSwitch) { dayNightSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override/*ww w .j a va 2s. c o m*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { changeToNight(); MyUtils.saveTheme(true); } else { changeToDay(); MyUtils.saveTheme(false); } mIsChangeTheme = true; mDrawerLayout.closeDrawer(GravityCompat.START); } }); }