Verified
Status Update
Comments
ja...@google.com <ja...@google.com> #2
I have the same issue. There should be a built in method for setting title dynamically.
cc...@google.com <cc...@google.com> #3
I would expect a simple API inside the navigation architecture as this is quite a common design requirement
cc...@google.com <cc...@google.com> #4
To me, it is perfectly reasonable to remove the `android:label` attribute from the nav_graph.xml and set the title manually based on the arguments bundle.
cc...@google.com <cc...@google.com> #5
I'm currently working around this limitation by adding an "onNavigatedListener" to my root Activity and using the "destination.id " property against a lookup mapping to a desired title:
private val onNavigatedListener: (NavController, NavDestination) -> Unit = { _, destination ->
this.title = titleLookup[destination.id ]
}
private val onNavigatedListener: (NavController, NavDestination) -> Unit = { _, destination ->
this.title = titleLookup[
}
cc...@google.com <cc...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit a958e3d36aeca8767d1c3cb53caa55ba3dd1c65d
Author: Ian Lake <ilake@google.com>
Date: Wed Nov 28 16:06:01 2018
Allow {argName} parameterized labels
Support parameterized labels similarly
to how ActivityNavigator uses dataPattern by
using {argName} blocks in the label.
Test: testapp works
BUG: 80267266
Change-Id: I923f3a6e11662c4364d4b3f0757361edea016cec
M navigation/integration-tests/testapp/src/main/res/navigation/nav_main.xml
M navigation/integration-tests/testapp/src/main/res/values/strings.xml
M navigation/ui/src/main/java/androidx/navigation/ui/AbstractAppBarOnNavigatedListener.java
https://android-review.googlesource.com/837143
https://goto.google.com/android-sha1/a958e3d36aeca8767d1c3cb53caa55ba3dd1c65d
Branch: androidx-master-dev
commit a958e3d36aeca8767d1c3cb53caa55ba3dd1c65d
Author: Ian Lake <ilake@google.com>
Date: Wed Nov 28 16:06:01 2018
Allow {argName} parameterized labels
Support parameterized labels similarly
to how ActivityNavigator uses dataPattern by
using {argName} blocks in the label.
Test: testapp works
BUG: 80267266
Change-Id: I923f3a6e11662c4364d4b3f0757361edea016cec
M navigation/integration-tests/testapp/src/main/res/navigation/nav_main.xml
M navigation/integration-tests/testapp/src/main/res/values/strings.xml
M navigation/ui/src/main/java/androidx/navigation/ui/AbstractAppBarOnNavigatedListener.java
Description
Jake, is this something like what you had in mind:
ViewModel:
public LiveData<Pair<String, PagedList<Item>>> list;
Activity:
viewModel.list.observe(this, it -> submitList(it.second, () -> setTitle(it.first)));