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.example.android.navigationdrawerexample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StrictMode.enableDefaults(); //STRICT MODE ENABLED db = new DBHelper(this); session = new Session(getApplicationContext()); inflatedView = getLayoutInflater().inflate(R.layout.full_layout, null); mTitle = mDrawerTitle = getTitle();//from w w w . java2 s.co m login_layout = (RelativeLayout) findViewById(R.id.login_layout); // order_list_layout= (RelativeLayout) findViewById(R.id.order_list_layout); signup_layout = (RelativeLayout) findViewById(R.id.signup_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); actionBar = getActionBar(); text = (TextView) inflatedView.findViewById(R.id.user_name); login_option = (TextView) inflatedView.findViewById(R.id.textView1); mDrawerList = (ListView) findViewById(R.id.left_drawer); order_list = (ListView) findViewById(R.id.order_list); final LayoutInflater factory = getLayoutInflater(); final View vendor_menu = factory.inflate(R.layout.vendor_menu, null); final View order_menu = factory.inflate(R.layout.my_order, null); menu_list = (ListView) vendor_menu.findViewById(R.id.menu_list); // loginPopup= (TextView) vendor_menu.findViewById(R.id.menu_title); // Log.d //menu_list.addView(order_menu,0); Signup = (Button) findViewById(R.id.Signup); Gosignup = (Button) findViewById(R.id.Gosignup); Login = (ImageButton) findViewById(R.id.Login); Sign_username = (EditText) findViewById(R.id.SignUsername); Sign_name = (EditText) findViewById(R.id.vendor); Sign_pass = (EditText) findViewById(R.id.SignPass); Sign_cpass = (EditText) findViewById(R.id.SignCpass); Sign_phone = (EditText) findViewById(R.id.Phone); Login_pass = (EditText) findViewById(R.id.Logpass); Login_email = (EditText) findViewById(R.id.Logusername); // Log_username= (EditText) findViewById(R.id.Logusername); // 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 adapter = new MyAdapter(this); //adapter2=new MyAdapter2(this); // menu_adapter=new MyAdapter2(this); mDrawerList.setAdapter(adapter); mDrawerList.setDividerHeight(0); //mDrawerList.setAdapter(adapter); // order_list.setAdapter(adapter2); // menu_list.setAdapter(menu_adapter); menu_list.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, adapter.mPlanetTitles)); ImageView floatoption = new ImageView(this); floatoption.setImageResource(R.drawable.foption); ImageView floatadd = new ImageView(this); floatadd.setImageResource(R.drawable.fplus); floatin = new ImageView(this); floatin.setImageResource(R.drawable.flogin); floatout = new ImageView(this); floatout.setImageResource(R.drawable.flogout); ImageView floatrefresh = new ImageView(this); floatrefresh.setImageResource(R.drawable.refresh); itemBuilder = new SubActionButton.Builder(this); loginout = itemBuilder.setContentView(floatin).build(); refresh = itemBuilder.setContentView(floatrefresh).build(); additem = itemBuilder.setContentView(floatadd).build(); actionButton = new FloatingActionButton.Builder(this).setContentView(floatoption).build(); actionMenu = new FloatingActionMenu.Builder(this).addSubActionView(loginout).addSubActionView(additem) .addSubActionView(refresh) // ... .attachTo(actionButton).build(); Signup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View v = mDrawerList.getChildAt(0); View v2 = mDrawerList.getChildAt(5); text = (TextView) v.findViewById(R.id.user_name); login_option = (TextView) v2.findViewById(R.id.textView1); profile = (ImageView) v.findViewById(R.id.user_image); profile.setImageResource(R.drawable.welcome); text.setTextSize(20); text.setTextColor(Color.MAGENTA); text.setText("" + Sign_name.getText().toString()); login_option.setText("Logout"); floatout.setImageResource(R.drawable.flogout); // loginout.setContentView(floatout); long id = db.Insert(Sign_username.getText().toString(), Sign_name.getText().toString(), Sign_pass.getText().toString(), Sign_phone.getText().toString()); Log.d("This is-----------==", (String) text.getText() + id); //mDrawerList.invalidateViews(); //mDrawerList.removeViewAt(0); adapter.notifyDataSetChanged(); loginout.removeView(floatin); loginout.setContentView(floatout); order_list.setVisibility(View.VISIBLE); signup_layout.setVisibility(View.INVISIBLE); login_layout.setVisibility(View.INVISIBLE); } }); Login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { user_name = Login_email.getText().toString(); user_pass = Login_pass.getText().toString(); new GetAllCustomerTask().execute(new ApiConnector()); new Order_details().execute(new ApiConnector()); } }); if (!session.getusename().equals("")) { user_id = session.getusename(); user_name = session.getusename(); user_pass = session.getpassword(); login_layout.setVisibility(View.INVISIBLE); new GetAllCustomerTask().execute(new ApiConnector()); // new Order_details().execute(new ApiConnector()); // View vt = mDrawerList.getChildAt(0); //login_check(jsonArray); //new Order_details().execute(new ApiConnector()); } additem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logged_in) { Intent i = new Intent(getApplicationContext(), Add_Item.class); startActivity(i); } else Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show(); } }); loginout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logged_in) { session.setusename("", ""); finish(); startActivity(getIntent()); Toast.makeText(getApplicationContext(), "You are Loged Out", Toast.LENGTH_SHORT).show(); } else Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show(); } }); Login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { user_name = Login_email.getText().toString(); user_pass = Login_pass.getText().toString(); new GetAllCustomerTask().execute(new ApiConnector()); // new Order_details().execute(new ApiConnector()); } }); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); order_list.setOnItemClickListener(new OrderItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); ActionBar actionBar = getActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(0xFF3BBD8F)); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() text = (TextView) inflatedView.findViewById(R.id.user_name); Log.d("Thit is----------------", (String) text.getText()); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:com.dm.wallpaper.board.activities.WallpaperBoardActivity.java
@Override public void onBackPressed() { if (mFragManager.getBackStackEntryCount() > 0) { clearBackStack();//from www. j ava 2 s. c om return; } if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mDrawerLayout.closeDrawers(); return; } if (!mFragmentTag.equals(Extras.TAG_WALLPAPERS)) { mPosition = mLastPosition = 0; setFragment(getFragment(mPosition)); return; } super.onBackPressed(); }
From source file:com.example.android.materialdesigncodelab.ui.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_stopmock) { return true; } else if (id == android.R.id.home) { mDrawerLayout.openDrawer(GravityCompat.START); } else if (id == R.id.action_custom_location) { return true; }// ww w . j av a2 s. c o m return super.onOptionsItemSelected(item); }
From source file:com.battlelancer.seriesguide.ui.BaseNavDrawerActivity.java
public void closeNavDrawer() { mDrawerLayout.closeDrawer(GravityCompat.START); }
From source file:com.actionbarsherlock.plus.SherlockActionBarToggle.java
protected void openView() { switch (view_type) { case Slider://from w w w . java 2s . co m mSlidingPaneLayout.openPane(); break; case Drawer: mDrawerLayout.openDrawer(GravityCompat.START); break; } }
From source file:com.example.messaging.MessageActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_home) { Intent intent = new Intent(this, HomePage.class); startActivity(intent);/*ww w. j av a 2 s . c om*/ finish(); } else if (id == R.id.nav_teammates) { Intent intent = new Intent(this, SelectGM_Activity.class); startActivity(intent); finish(); } else if (id == R.id.nav_messages) { Intent intent = new Intent(this, GroupTextActivity.class); startActivity(intent); finish(); } else if (id == R.id.nav_leave_sport) { Intent intent = new Intent(this, SelectSport.class); startActivity(intent); finish(); } else if (id == R.id.nav_settings) { Intent intent = new Intent(this, DefaultSettingsActivity.class); startActivity(intent); finish(); } else if (id == R.id.nav_logout) { Intent intent = new Intent(this, FacebookLoginActivity.class); startActivity(intent); finish(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.message_drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.dycody.android.idealnote.MainActivity.java
public void onBackPressed() { Fragment f;//from w w w . ja v a 2s.co m // SketchFragment f = checkFragmentInstance(R.id.fragment_container, SketchFragment.class); if (f != null) { ((SketchFragment) f).save(); // Removes forced portrait orientation for this fragment setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); mFragmentManager.popBackStack(); return; } // DetailFragment f = checkFragmentInstance(R.id.fragment_container, DetailFragment.class); if (f != null) { ((DetailFragment) f).goBack = true; ((DetailFragment) f).saveAndExit((DetailFragment) f); return; } // ListFragment f = checkFragmentInstance(R.id.fragment_container, ListFragment.class); if (f != null) { // Before exiting from app the navigation drawer is opened if (prefs.getBoolean("settings_navdrawer_on_exit", false) && getDrawerLayout() != null && !getDrawerLayout().isDrawerOpen(GravityCompat.START)) { getDrawerLayout().openDrawer(GravityCompat.START); } else if (!prefs.getBoolean("settings_navdrawer_on_exit", false) && getDrawerLayout() != null && getDrawerLayout().isDrawerOpen(GravityCompat.START)) { getDrawerLayout().closeDrawer(GravityCompat.START); } else { if (!((ListFragment) f).closeFab()) { super.onBackPressed(); } } return; } super.onBackPressed(); }
From source file:com.example.ivonneortega.the_news_project.detailView.CollectionDemoActivity.java
/** * Method that handles the clicks on each item in the navigation drawer * @param item is the item that has been clicked * @return// w ww .ja va2 s. c om */ @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_world) { moveToCategoryViewActivity("World"); } else if (id == R.id.nav_politics) { moveToCategoryViewActivity("Politics"); } else if (id == R.id.nav_business) { moveToCategoryViewActivity("Business"); } else if (id == R.id.nav_technology) { moveToCategoryViewActivity("Technology"); } else if (id == R.id.nav_science) { moveToCategoryViewActivity("Science"); } else if (id == R.id.nav_sports) { moveToCategoryViewActivity("Sports"); } else if (id == R.id.nav_movies) { moveToCategoryViewActivity("Movies"); } else if (id == R.id.nav_fashion) { moveToCategoryViewActivity("Fashion"); } else if (id == R.id.nav_food) { moveToCategoryViewActivity("Food"); } else if (id == R.id.nav_health) { moveToCategoryViewActivity("Health"); } else if (id == R.id.nav_miscellaneous) { moveToCategoryViewActivity("Miscellaneous"); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:at.tugraz.ist.akm.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } else {/*w ww . j av a 2 s. co m*/ mDrawerLayout.openDrawer(GravityCompat.START); } return false; }
From source file:com.battlelancer.seriesguide.ui.BaseNavDrawerActivity.java
public boolean toggleDrawer(MenuItem item) { if (item != null && item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } else {//from ww w. j av a 2 s . com mDrawerLayout.openDrawer(GravityCompat.START); } return true; } return false; }