ViewCompositionStrategy在 Jetpack compose 中使用Compose ViewXML时有什么区别?
https://developer.android.com/jetpack/compose/interop/interop-apis#composition-strategy https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy
ViewCompositionStrategy当以下情况时需要什么:
<ComposeView>在活动布局中<ComposeView>在片段布局中<ComposeView>在片段中的自定义视图中(我假设与上面相同?)我一直在阅读https://developer.android.com/topic/libraries/view-binding并正在考虑他们如何在片段中定义视图绑定属性。
这是示例代码:
private var _binding: ResultProfileBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = ResultProfileBinding.inflate(inflater, container, false)
val view = binding.root
return view
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
Run Code Online (Sandbox Code Playgroud)
可为空也是如此_binding,因为对视图的引用将在 中被销毁onDestroyView()。然而,它们用作binding支持属性,它检索_binding并使其不可为 null(无论 Kotlin 中调用的强制展开的等效项是什么)。
问题是为什么我们应该拥有_binding以及binding应该使用哪一个?感觉就像如果您试图使其可为_binding空,那么为什么要使其本质上不可为空 …
如果启动了协程并且未指定调度程序(例如GlobalScope.launch {}),则使用什么调度程序?
如果该协程在主线程中启动,它会使用 吗Dispatchers.main?
另外,如果您没有在协程中指定调度程序或上下文,会发生什么情况?假设您进行了数据库操作,但没有Dispatchers.IO在任何地方指定。这会导致任何重大问题吗?
我正在尝试使用最新的稳定 Flamingo 版本将我的 Android Gradle 插件升级到 8.0。
但是,在运行 AGP 升级助手并尝试运行构建后,我遇到了这个问题。
Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
Run Code Online (Sandbox Code Playgroud)
我已经更新了 build.gradle 文件中的这些行
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
Run Code Online (Sandbox Code Playgroud)
但是,我仍然遇到这个问题。
这个问题是什么意思以及如何解决它?
我知道使用导航组件,您可以轻松设置toolbar以使用它(https://developer.android.com/guide/navigation/navigation-ui#create_a_toolbar)。
你打电话setupWithNavController,一切就会神奇地发生。然后,只要您不在起始目的地,您就会看到一个后退箭头。
我目前正在使用 Jetpack Compose,但对它还是个新手。我正在尝试查看导航组件是否能够执行与 aTopAppBar中类似的操作Scaffold。
有没有一种简单的方法可以使用 来设置导航组件TopAppBar,或者我的导航图标(后退箭头)是否需要手动完成(为这些图标调用navController.popBackStack)onClick?
android android-appbarlayout android-architecture-navigation android-jetpack-compose
我将登录流程从 XML 重构为 Compose。
旧的登录流程在成功登录后,Google 会建议保存您的密码。
然而,自从我重构它之后,它就不再这样做了。
旧的 XML 布局仅使用TextInputLayout和TextInputEditText。新的可组合项只是OutlinedTextField带有一些键盘选项。
<com.google.android.material.textfield.TextInputLayout
style="@style/TextInputLayoutStyle"
android:theme="@style/TextInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
android:hint="@string/password">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
OutlinedTextField(
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Password,
imeAction = ImeAction.Done
)
)
Run Code Online (Sandbox Code Playgroud)
为什么 Google 不建议保存密码?新旧代码都在同一模拟器上运行,该模拟器启用了自动填充服务。
我正在我的 Android 应用程序中使用 Google 应用内结算 API 测试 IAP。我进行了测试购买,然后在 Google Play 管理中心进行了退款。我可以看到订单状态现已退款。
但是,当我运行该应用程序时,我可以看到BillingClient仍然可以找到已退款的购买(与退款订单相同的订单号匹配)。
之前的退款可以用,但现在不行了。我认为问题在于queryPurchasesAsync可能正在使用缓存结果而无法获取用户最新购买的内容。
基于对客户应用内购买进行退款,但 BillingClient 仍表明用户已购买?,建议打电话queryPurchaseHistoryAsync尝试清除缓存。我已经完成此操作并等待了 24 小时,但仍然可以在购买列表中看到该购买。
这里有什么问题吗?
我正在toolargetool调查应用程序崩溃的原因TransactionTooLargeException。
androidx.lifecycle.BundlableSavedStateRegistry.key当我将应用程序置于后台时,我看到这个密钥大约有 400 KB。
这个密钥是什么以及它从哪里来?我怎样才能减少包中这个的大小?