navigation-drawer

Adding a linear layout to Navigation drawer (ends up crashing with a ClassCastException)

六眼飞鱼酱① 提交于 2019-11-27 03:31:30
问题 I am trying to add a vertical linear layout (having a title, image, menu title, listview and an icon at the bottom)to the navigation drawer. However the app crashes displaying 'java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams' error. I am not sure if this is possible straight ways as I checked couple of links and the only close I got was this. Any help is appreciated. Thanks in advance. Here is my code

How to open a new fragment from the navigation drawer?

空扰寡人 提交于 2019-11-27 03:21:34
问题 I'm using developer.android.com guides to build an app. I choosed "Navigation: Navigation Drawer" when I made a new project in Android Studio. I have searched the internet for answers to my questions but I can't find any that works. Sorry about this, I'm new to programming. How do I make my app open a new fragment in the main view when clicking in the navigation drawer? Is it possible to open multiple swipeable fragments with tabs when clicking in the navigation drawer? How do I make a "title

Changing Navigation drawer icon on action bar android

不羁岁月 提交于 2019-11-27 03:03:04
问题 I have created a NavigationDrawer in my app using the ActionBar. As showed in the picture above I want to change the NavigationDrawer toggle button icon to something I want. How can I change it? Here is my code:- mDrawerList.setOnItemClickListener(new SlideMenuClickListener()); // enabling action bar app icon and behaving it as toggle button getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,

Customising NavigationView - Adding dynamic headerView, Android Support Design Library

半城伤御伤魂 提交于 2019-11-27 02:35:49
问题 I tried the navigationView from the new android support design library. I want to have a dynamic headerview. Basically, my headerview will show something like quote of the day. I have like around 10 quotes and i want to randomly select a quote and display in a textview in the headerView. I also want to add onClick method for the headerView. Right now, I don't see any possibilities of changing the headerview layout programmatically. Any suggestions to implement this? 回答1: first create header

Can I open the drawer layout with animation programmatically?

不问归期 提交于 2019-11-27 02:35:29
问题 I created the app drawer by using the following library: http://developer.android.com/training/implementing-navigation/nav-drawer.html I want to show the Navigation Drawer with animation when opening the app. How can I do that? 回答1: Predraw listener, aka the safeway Here is the predraw listener example. It will literally start the animation as soon as it can which maybe a little too fast. You might want to do a combination of this with a runnable shown second. I will not show the two combined

How to impliment navigation drawer and swipe tab in same activity in android studio?

妖精的绣舞 提交于 2019-11-27 02:27:36
问题 I have done both separately and I want to combine the both activity in single activity. I can't get any idea what should I do. Please please help me. MainActivity.java Public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

onClick event in navigation drawer

馋奶兔 提交于 2019-11-27 01:57:08
问题 I have made a navigation drawer in Android in which I want to implement onClick for it. This is my main activity: public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ActionBarDrawerToggle aToggle; private Toolbar toolbar; private RecyclerView recyclerView; private RecyclerAdapter recyclerAdapter; private RecyclerView.Adapter adapter; private NavigationView navigationView; @Override protected void onCreate(Bundle savedInstanceState) { super

Navigation Drawer Menu Item Title Color in Android

耗尽温柔 提交于 2019-11-27 01:51:23
问题 I have a problem changing the Menu Item Title Color in the Navigation Drawer I set the itemTextColor but it only changes the Color of the Items not the Title of the menu. Here is my Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match

OnClick for navigation drawer header not working

北城余情 提交于 2019-11-27 01:48:42
问题 I have a navigation drawer in my app which contains a header and some list items. The header has a textview which i want to make clickable but I am not able to do it. To get the id of this textview I used the following code, since it is in a different layout file compared to the one in the setContentView in onCreate. final LayoutInflater factory = getLayoutInflater(); final View textEntryView = factory.inflate(R.layout.header, null); TextView home = (TextView) textEntryView.findViewById(R.id

Android DrawerLayout - No drawer view found with gravity

三世轮回 提交于 2019-11-27 01:41:19
When I click on my drawer toggle I get the following exception: java.lang.IllegalArgumentException: No drawer view found with gravity LEFT This is my activity_drawer.xml : <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android