android-navigation

How to prevent previous fragment to show up after pressing back button using navigation controller?

我的梦境 提交于 2019-12-01 22:33:23
I am trying to use the navigation controller right now. I want to move from LoginFragment to HomeFragment . In LoginFragment I use this code below to move to HomeFragment . Navigation.findNavController(view).navigate(homeDestination) However, when I tap the back button in the HomeFragment , it will go back to LoginFragment , I expect that when I tap the button it will close the app. In old way, if I use activity instead of using Fragment , I usually do something like this to get that expected behaviour: val intent = Intent(this,HomeActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY

How do I set the parent activity of an activity at runtime?

我的梦境 提交于 2019-12-01 18:17:55
I have an arbitrary number of hierarchically nested views/activities. The action bar should show the Up navigation button to navigate to a higher level in any view. For this, the google documentation says I have to set the parent activity with a tag in the activity's xml definition. However, I'm creating my activities dynamically and a child element can be of the same activity as it's parent. So how do I set the parent activity to the actual parent instance at runtime? It sounds like you are confusing up and back navigation. The up button should be deterministic. From a given screen, the up

2 ViewPager not scrolling in Android 2.3

僤鯓⒐⒋嵵緔 提交于 2019-12-01 03:59:06
I am using Navigation Drawer in my app, that contains some Fragments just like in the below picture. Every Fragment Contains another ViewPager that is an ImageSlider, and below that is a Listview and at the top I am using the SwipeRefreshLayout. My problem is the image slider works well on devices that has Android version 3.0 or higher but the swipe left or right doesn't works on devices 2.3 and lower, instead it invokes the Parent ViewPager's swipe that is it navigates the fragment. I am using support Version 4 library for this purpose to support devices lower than 3.0. All functions works

Recycler View Not Showing

╄→尐↘猪︶ㄣ 提交于 2019-12-01 02:10:58
I have been making an app that uses a recycler view in a navigation drawer how the contents of the recycler view have not been showing up. The view is definitely their as I can see the scroll shadows. I am not sure want I have done wrong as the app does not crash when it is ran. Navigation Drawer Fragment: public class NavigationDrawerFragment extends android.support.v4.app.Fragment { public static final String PREF_FILE_NAME = "testPref"; public static final String KEY_USER_LEARNED_DRAWER = "user_learned_drawer"; private RecyclerView mRecyclerView; private ActionBarDrawerToggle mDrawerToggle;

Android - Navigation drawer fragments

不羁的心 提交于 2019-11-30 23:45:56
I have implemented navigation drawer in my android app. but now I want to be able to change the layout using fragments when the user clicks any list item in the navigation bar. Here is what I have got so far: XML <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:background="#000000" android:layout_height="match_parent" >

Recycler View Not Showing

泄露秘密 提交于 2019-11-30 21:33:28
问题 I have been making an app that uses a recycler view in a navigation drawer how the contents of the recycler view have not been showing up. The view is definitely their as I can see the scroll shadows. I am not sure want I have done wrong as the app does not crash when it is ran. Navigation Drawer Fragment: public class NavigationDrawerFragment extends android.support.v4.app.Fragment { public static final String PREF_FILE_NAME = "testPref"; public static final String KEY_USER_LEARNED_DRAWER =

Android parent Navigation Drawer for all activities

こ雲淡風輕ζ 提交于 2019-11-30 16:00:46
I am creating an app which requires same Navigation Drawer for all activities. To do so, I have created a class which extends Activity (need for child classes) and written the code for Navigation Drawer there. public class NavigationDrawerClass extends Activity { String [] names = new String[]{"Rohan", "Muthu","Rishi"}; private ActionBarDrawerToggle mDrawerToggle; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.navigation_drawer_class); DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ListView

Navigation graph with multiple top level destinations

▼魔方 西西 提交于 2019-11-30 15:05:54
问题 I am implementing an android app (in Kotlin, but that is not relevant to the Problem) in my free time and I try to use android jetpack and new libraries. I have a single Activity with a navigation drawer. I try to follow the sample sunflower app. It uses the following combination in the main activity to enable the logic behind the navigation drawer: appBarConfiguration = AppBarConfiguration(navController.graph, drawerLayout) setSupportActionBar(findViewById(R.id.toolbar))

Navigation graph with multiple top level destinations

情到浓时终转凉″ 提交于 2019-11-30 13:01:13
I am implementing an android app (in Kotlin, but that is not relevant to the Problem) in my free time and I try to use android jetpack and new libraries. I have a single Activity with a navigation drawer. I try to follow the sample sunflower app . It uses the following combination in the main activity to enable the logic behind the navigation drawer: appBarConfiguration = AppBarConfiguration(navController.graph, drawerLayout) setSupportActionBar(findViewById(R.id.toolbar)) setupActionBarWithNavController(navController, appBarConfiguration) Note on this code : This automatically will navigate

Navigation Drawer without Actionbar

南笙酒味 提交于 2019-11-30 12:01:20
I searched many sites (stackoverflow as well) but couldn't understand how to implement the navigation drawer without the action bar. I know that this question has already been asked here but it doesn't have a proper explanation and code. I am a beginner in android development so can anyone please explain me with code How to make a navigation drawer without an action bar Thanks in advance! Just add your DrawerLayout like @mohan did, then if you have a button or something you tap on and want to open the drawer, just do like this : drawer.openDrawer(Gravity.LEFT); and to close : drawer