android-navigation

How do I change my button image with navigation drawer opening and closing

荒凉一梦 提交于 2019-12-04 15:48:19
I have a navigation button for my navigation fragment which turns active and opens a navigation drawer menu upon click: Now when I click it, it turns active as follows: However, I want to associate it with a navigation drawer such a way that, even if I do not click the button and slide open the navigation drawer, the button turns active when the navigation drawer menu is open and when closed by sliding back in from right to left, the button turns red/inactive. The code which I am trying to work with is as follows: private boolean mIsNavigationOpen = false; private DrawerLayout drawerLayout;

Android Navigation Drawer ListView Headers

£可爱£侵袭症+ 提交于 2019-12-04 13:02:36
I've made a navigation drawer in my app. Inside my navigation drawer is a ListView . It's a simple list view with text items. The Gmail android app has a ListView with headers. (source: phonedog.com ) As you can see, the words: INBOX, RECENT LABELS, ALL LABELS are headers. I would like to implement exactly those type of headers into my app. Is this feature an inbuilt android thing or do I have to create something custom. If yes then how. Let me know if you need any more info. Thanks in Advance. 来源: https://stackoverflow.com/questions/19341033/android-navigation-drawer-listview-headers

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

南笙酒味 提交于 2019-12-04 03:42:44
问题 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? 回答1: It sounds like you

How to set target fragment of a dialog when using navigation components

∥☆過路亽.° 提交于 2019-12-04 03:07:32
I'm showing a dialog inside a fragment using childFragmentManager or within an Activity using the supportFragmentManager , in the process I would like to set the target fragment, like this: val textSearchDialog = TextSearchDialogFragment.newInstance() textSearchDialog.setTargetFragment(PlaceSearchFragment@this, 0) But when running that code I get the error: java.lang.IllegalStateException: Fragment TextSearchDialogFragment{b7fce67 #0 0} declared target fragment PlaceSearchFragment{f87414 #0 id=0x7f080078} that does not belong to this FragmentManager! I don't know how to access the

How to implement android Toolbar Back button

≡放荡痞女 提交于 2019-12-03 20:39:00
问题 I am using a custom toolbar. I need to add back button to it. Now I am using this code to add the back button. Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar); toolbar.setBackgroundColor(getResources().getColor(R.color.white)); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.back_arrow)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); This works fine. I can see the back

Calculating Speed for a navigation app without getSpeed() method

一世执手 提交于 2019-12-03 19:04:56
问题 I am developing an app which is more of a time-shift racing between your friends. I need to calculate speed of a moving vehicle, and I don't want to use Location.getSpeed() method. (Explained in detail in the bottom why I don't want to use it) I am trying to calculate speed with the help of Latitude and Longitude available to me, and this is where I need help. The help needed: I would want to know is: If the algorithm is correct Should I calculate in Centimeters instead of meters And if there

How to add draggable icon with navigation drawer

耗尽温柔 提交于 2019-12-03 13:37:14
My problem: I want to add draggable icon in navigation drawer. This icon combined with listview of navigation drawer when drawer open. see similar like this, What I have tried, I searched in StackOverflow like similar question this, Draggable drawer with a handle (instead of action bar) on top of other apps But all answer suggest to 3rd party library. My question 1.It`s possible to add draggable icon with navigation drawer? For drag layout there is github library which is useful for it You can drag from left to right or any where. It will also slide from left to right & also drag is also

Android : Return to previous fragment on back press

我是研究僧i 提交于 2019-12-03 10:02:07
I have implemented Navigation Drawer which is a subclass of Activity. I have many fragments in my application. My question goes here Imagine there are 3 fragments : Fragment_1 : Fragment_2 : Fragment_3 When I start my application, Fragment_1 is loaded When I click on some components on Fragment_1, I'm navigated to Fragment_2 and so on.. So it's like Fragment_1 > Fragment_2 > Fragment_3 When I press back key from Fragment_2, I'm navigated back to Fragment_1 But when I press back key from Fragment_3, I'm navigated back to Fragment_1 (instead of Fragment_2) I want something like this in my

Remove up button from action bar when navigating using BottomNavigationView with Android Navigation UI library

隐身守侯 提交于 2019-12-03 09:14:50
问题 I've created a small app that has three fragments for top-level navigation through a BottomNavigationView. If you launch the app and click on a navigation button on the bottom nav, you are presented with an up button in the action bar. Here is the code for the activity: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.main_activity) setSupportActionBar(toolbar) val navController =

Android Navigation Architecture Component - Get current visible fragment

假装没事ソ 提交于 2019-12-03 08:06:10
问题 Before trying the Navigation component I used to manually do fragment transactions and used the fragment tag in order to fetch the current fragment. val fragment:MyFragment = supportFragmentManager.findFragmentByTag(tag):MyFragment Now in my main activity layout I have something like: <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/nav_host" app:navGraph= "@navigation/nav_item" android:name="androidx.navigation.fragment.NavHostFragment" app