navigation-drawer

How to put list items at the bottom of list view in Navigation Drawer like Foursquare

六眼飞鱼酱① 提交于 2019-11-27 14:01:12
I got a list view for navigation drawer, how can I put list item like "Add Friends", "Settings" align at the bottom of the list view. Update 1 I add a setting view to the footer view. View settingView = getLayoutInflater().inflate(R.layout.drawer_list_item, null); TextView textView = (TextView)settingView.findViewById(R.id.drawer_list_item_text_view); textView.setText("Settings"); drawerListView.addFooterView(settingView); The settings item appear at the last one in the list view successfully. But how can I make it to stick and align at the bottom? Thanks. You can put the ListView inside a

OnItemClickListener Navigation Drawer

陌路散爱 提交于 2019-11-27 13:31:58
问题 I am making an app from the example of Android Developers with the Navigation Drawer. I made the items but I don't know how I can open new Activity from each of items enlisted. This is the MainActivity: public class MainActivity extends Activity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; private CharSequence mDrawerTitle; private CharSequence mTitle; private String[] mGalaxyTitles; @Override protected void onCreate(Bundle

ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams

五迷三道 提交于 2019-11-27 12:35:32
I'm working on the Navigation Drawer for Android. As per my requirement I was to display gridview and listview of items in the navigation drawer. I have created a linearLayout in the layout xml file and placed the two widgets(Grid view, and Listview) in the LinearLayout. When I run the file I'm getting the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navigationdrawer3/com.example.navigationdrawer3.MainActivity}: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout

How to detect that the DrawerLayout started opening?

£可爱£侵袭症+ 提交于 2019-11-27 12:01:02
So I have tabs that I want to hide when the Navigation Drawer starts opening. The code I have hides them when it finished opening, but it's not what I want. mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) { @Override public void onDrawerClosed(View view) { invalidateOptionsMenu(); setActionBarMode(ActionBar.NAVIGATION_MODE_TABS); } @Override public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); setActionBarMode(ActionBar.NAVIGATION_MODE_STANDARD); } }; mDrawerLayout.setDrawerListener

Android Navigation Drawer over the tabs

放肆的年华 提交于 2019-11-27 11:56:13
I am using the new navigation drawer available from the support library. When using the drawer along with tabs, the drawer menu is getting displayed below the tabs as shown below. How can i make sure the drawer menu is shown on the tabs. (It should display the drawer menu as if there are no tabs) Drawer menu without tabs Drawer menu with tabs I got the same issue and the answer I got from Roman Nurik (Android team) is that the Navigation Drawer should not be used with the Action Bar tabs. The discussion can be found here: https://plus.google.com/u/1/116515063230772720916/posts/8dWEkFcbTFX

Manage toolbar's navigation and back button from fragment in android

血红的双手。 提交于 2019-11-27 11:40:48
All of my fragments are controlled through ActionBarActivity (mainActivity), inside mainActivity a DrawerLayout is implemented and all the child fragments are pushed through drawerLayout's list item click. The problem that I'm facing is after pushing a fragment through drawerLayout I want to change the drawer icon into back icon of ToolBar so that user can navigate to previous fragment and to handle the callback of android.R.id.home either inside the same fragment or inside the mainActivity. The code that I am using is: MainActivity.java public class MainActivity extends ActionBarActivity {

How can I add a custom item to a NavigationView with a menu layout?

馋奶兔 提交于 2019-11-27 11:38:58
I've been experimenting with simplifying some navigation drawer code by making use of the new NavigationView class in the Android design support library. It works great if you just want icons on the left, and text on the right like in the example in the documentation, but what if I want to add a single custom view to the layout which has an android.support.v7.widget.SwitchCompat like in the Google Play Movies app (see screenshot below)? I've tried using the actionLayout attribute to specify a custom layout file like in the example code below, however that attribute appeared to be ignored as it

Navigation drawer, handling the back button to go to previous fragments?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 11:34:24
I'm using the built in navigation drawer to run my app. I can't quite figure out how to handle the back button. When it's pressed I want it to load the very first fragment again. Fragment1. So when the app launches you see Fragment1 launched. They can then click on Fragment 2-5 to go to other pages. Within all of these pages I want the back button to take the user back to Fragment1. The only place the user should be able to exit the app via the back button is Fragment1. SInce it's all handled by a FragmentActivity I tried messing with the backbutton there. I keep getting a force close error

Change NavigationView items when user is logged

☆樱花仙子☆ 提交于 2019-11-27 11:12:00
My app's main activity has a navigation drawer, instantiated in the XML in this way: <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/drawer_header" app:menu="@menu/application_drawer" android:background="@color/white"/> Now, the menu entry for the navigation drawer is the following: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android

Set drag margin for Android Navigation Drawer

本秂侑毒 提交于 2019-11-27 11:07:49
I am using the new Navigation Drawer in my app. It is great except I have not found an easy way to set how the drawer is open. The default behavior is drag from the left edge of the screen to open. This is fine, unless the phone/table has a case on and the edge of phone can not be touched. I would like to allow the user to touch and drag from a margin of the screen to the left. This is easy to set with other nav drawer libs(Sliding lib). I have not seen anything with Google's lib unfortunately. There is an onTouchEvent() method for the NavigationLayout that could may be used. Of course you