我正在尝试添加一个侦听器,并在 Jetpack Compose 中完成导航转换时接收回调。
我尝试使用 NavController API addOnDestinationChangedListener,但它会立即发送到我的侦听器,并且不会等待合成完成。
val navController = rememberNavController()
// Register the destination changed listener
navController.addOnDestinationChangedListener { _, destination, _ ->
// destination change is sent immediately and isnt waiting for the composable to finish
}
Run Code Online (Sandbox Code Playgroud)
我的目标是添加一个侦听器,仅在合成完成且目的地更改后才会触发该侦听器。
像这样的东西:
// Register the transition finished listener
navController.transitionFinished{ _, destination ->
// Do something when the navigation transition has finished
}
NavHost(navController = navController, startDestination = "Home") {
composable("Home") {
// THE CALLBACK IS FIRED HERE, IMMEDITIETLY
Text("FIRST SITE") …Run Code Online (Sandbox Code Playgroud) android kotlin android-jetpack android-jetpack-navigation android-jetpack-compose
我有以下代码:
vector<UINT_PTR> test = GetMemoryAddresses();
cout << "Size: " << test.size() << endl;
for (UINT_PTR a : test) {
cout << "Memory Address: " << hex << a << endl;
}
cout << "Size: " << test.size() << endl;
Run Code Online (Sandbox Code Playgroud)
打印以下结果:
Size: 18
Memory Address: fc06a0
Memory Address: 13a70f0
Memory Address: 36c78c1
Memory Address: 3da0ea0
Memory Address: 3e21b80
Memory Address: c0a6881
Memory Address: c747690
Memory Address: c748b98
Memory Address: c74a1b8
Memory Address: c74ce10
Memory Address: c750c78
Memory Address: 1340a10f
Memory Address: …Run Code Online (Sandbox Code Playgroud) 我想使用这个库见:https : //github.com/jtv/libpqxx
我决定安装这个库管理器 vcpkg 见:https : //github.com/microsoft/vcpkg
我将 CMake 选项设置为“CMake 项目应该使用:”-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake”
这是错误:
"C:\Program Files\JetBrains\CLion 2019.1.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/vcpkg/scripts /buildsystems/vcpkg.cmake -G "CodeBlocks - MinGW Makefiles" C:\Users \Vaio\CLionProjects\untitled
CMake Warning at C:/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake:68 (message):
Unable to determine target architecture, continuing without vcpkg.
Call Stack (most recent call first):
cmake-build-debug-mingw/CMakeFiles/3.14.3/CMakeSystem.cmake:6 (include)
CMakeLists.txt:2 (project)
Run Code Online (Sandbox Code Playgroud)
相应的 CMake 代码是这样的:
if(VCPKG_TARGET_TRIPLET)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
if(CMAKE_GENERATOR MATCHES "^Visual Studio …Run Code Online (Sandbox Code Playgroud) 我尝试在他使用的地方使用这个答案OnGloballyPositionedModifier,但它没有返回我孩子的正确绝对 Pos。我尝试过positionInWindow(),positionInRoot()。当使用间距时它似乎有效,column但当我使用 时则无效offset。
@Composable
fun GetAbsolutePos(
content: @Composable () -> Unit,
) {
Box(modifier = Modifier
.onGloballyPositioned { coordinates ->
println("My coordinates: " + coordinates.positionInRoot())
}
) {
content()
}
}
@Preview
@Composable
fun test() {
GetAbsolutePos() {
Box(
modifier = Modifier
.width(PixelToDp(pixelSize = 200))
.offset(x = PixelToDp(pixelSize = 100), y = PixelToDp(pixelSize = 50))
.height(PixelToDp(pixelSize = 200))
.background(Color.Red)
) {
GetAbsolutePos() {
Column(
) {
GetAbsolutePos() { …Run Code Online (Sandbox Code Playgroud)