当尝试将 a 放入可滚动LazyVerticalGrid内容时,出现以下错误: Column
java.lang.IllegalStateException:不允许在同一方向嵌套可滚动布局,例如 LazyColumn 和 Column(Modifier.verticalScroll())。如果您想在项目列表之前添加标题,请查看 LazyColumn 组件,该组件具有 DSL api,允许首先通过 item() 函数添加标题,然后通过 items() 添加项目列表。
我不是在制作传统的列表,我只是有很多太大而无法在屏幕上显示的元素。因此,我希望该列滚动,以便我可以看到所有元素。这是我的代码:
@ExperimentalFoundationApi
@Composable
fun ProfileComposable(id: String?) {
val viewModel: ProfileViewModel = viewModel()
if (id != null) {
viewModel.getProfile(id)
val profile = viewModel.profile.value
val scrollState = rememberScrollState()
if (profile != null) {
Column(modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.verticalScroll(scrollState)) {
Row() {
ProfilePic(profile.getImgUrl(), profile.name)
Column(Modifier.padding(16.dp)) {
ProfileName(profile.name)
Stats(profile.stats) // <--------------- the offending composable
}
}
Sprites(sprites = profile.sprites)
TextStat(profile.id.toString(), "Pokemon Number")
TextStat(profile.species.name, "Species") …Run Code Online (Sandbox Code Playgroud) java.lang.NoSuchMethodError我在尝试运行时遇到异常setContent{ Composable() }。
完整代码:
class ComposeFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
ComposeView(requireContext()).apply { setContent { Text("hello") } }
}
Run Code Online (Sandbox Code Playgroud)
完整异常:
java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)V in class Landroidx/compose/ui/platform/ComposeView; or its super classes (declaration of 'androidx.compose.ui.platform.ComposeView' appears in /data/app/~~3OmVKUoYitZ_S4H81xmyuw==/my.app.package-PAQxAKmtRuhnzp4M2DME8w==/base.apk)
Run Code Online (Sandbox Code Playgroud)
类似问题的解决方案/答案建议添加buildFeatures { compose = true }或kotlinCompilerExtensionVersion,我已经这样做了,但问题仍然存在。
我的完整 Gradle 配置如下:
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
useIR = true
}
buildFeatures {
compose = true
}
composeOptions{
kotlinCompilerExtensionVersion = "1.0.5" …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我在主要活动中收到动态链接。当用户打开链接并启动应用程序并完成正确的操作时,这非常有效,但在应用程序中检索到动态链接后,它似乎仍然存在。
即使在用户按下链接并在应用程序中使用 检索它之后,用户也FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())可以关闭应用程序并在一段时间后重新打开它,getDynamicLink(getIntent())并且仍然会返回链接和意图中的数据。
一旦在应用程序中检索到链接及其数据,有没有办法丢弃该链接及其数据?我只需要做setIntent(null)吗?
这是我的 MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.ButtonTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
handleDynamicLink();
}
private void handleDynamicLink() {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, pendingDynamicLinkData -> {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
if(deepLink!=null){
String gameId = deepLink.getQueryParameter("id");
Intent intent = new Intent(this, MultiplayerActivity.class);
intent.putExtra("gameId",gameId);
startMultiplayerActivity(intent);
}
Log.d(TAG, "handleDynamicLink: bundle: "+deepLink.getQueryParameter("id"));
}
}).addOnFailureListener(this, e …Run Code Online (Sandbox Code Playgroud) 使用
com.squareup.retrofit2:retrofit:2.9.0
com.squareup.okhttp3:okhttp:4.4.0
com.google.firebase:firebase-perf-ktx (bom version is 29.0.4)
Run Code Online (Sandbox Code Playgroud)
我无法在 Firebase 性能网络请求部分中看到任何网络请求。自定义跟踪工作正常,但网络请求为空。我也看不到任何I/FirebasePerformance表明正在记录 http 请求的 logcat 日志。
该应用程序使用简单的改造服务来发出如下所示的请求:
Retrofit.Builder()
.baseUrl("https://myurl.com")
.client(get())
.addConverterFactory(MoshiConverterFactory.create(get()))
.build()
.create(MyService::class.java)
Run Code Online (Sandbox Code Playgroud)
这OkHttpClient:
OkHttpClient.Builder()
.addInterceptor(UserAgentHeaderInterceptor())
.addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
.build()
Run Code Online (Sandbox Code Playgroud)
我已经尝试过以下操作:
我正在尝试将 a 分配new Promise()给一个变量,然后将该变量推送到一个数组,从而产生一个承诺数组。然后我想稍后在按钮单击中执行这个承诺数组。
但是当将 分配Promise给变量时,它会立即执行。
ProcessExamples(){
swal({
title : 'Get Examples?',
confirmButtonText: 'Yes',
}).then( aRes => {
if( aRes.value ){
let lAllPromises = ExampleClass.GetExamplePromises();
}
});
}
static GetExamplePromises(){
let lPromises = [];
Examples.forEach( aExample => {
let lPromise = new Promise( ( resolve, reject ) => {
resolve( true );
});
lPromises.push( lPromise );
});
return lPromises;
}
Run Code Online (Sandbox Code Playgroud)
当承诺数组返回给ProcessExamples方法时,所有承诺都已解决。这不是我想要的,我该怎么办?
我试着更换拉姆达( resolve, reject ) => {}与function( resolve, reject ) {} …