在 Visual Studio 2022 中使用现有 git 存储库打开我的 ASP.NET Core 项目时,未加载 git 存储库。但是,从 GitHub 打开该项目的新克隆存储库效果很好。使用 git repos 打开其他项目效果很好。可能是什么问题?
我正在为基本对话框创建一个 Android 库。现在,我所拥有的只是一个basic-dialogs模块和一个app模块。我basic-dialogs从模块Activity中调用模块中的可组合项,当我尝试运行应用程序时,app我不断收到下面有关 a 的异常错误消息。No static method代码可能有什么问题?
java.lang.NoSuchMethodError: No static method BasicDialog(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Lcom/<domain>/basic_dialogs/BasicDialogKt; or its super classes (declaration of 'com.<domain>.basic_dialogs.BasicDialogKt' appears in /data/app/~~DOqVbMGsnzDWFS7_YdNgtw==/com.<domain>.composedialogs-_5IuirMOFh5F8pL884Urnw==/base.apk!classes2.dex)
Run Code Online (Sandbox Code Playgroud)
活动
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComposeDialogsTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
BasicDialog(onDismiss = { }, onConfirmClick = { …Run Code Online (Sandbox Code Playgroud) android android-gradle-plugin android-module android-jetpack-compose
Android Studio 抛出Unresolved Reference错误ScaffoldStatewith Material3. 我怎样才能让它发挥作用?
import androidx.compose.foundation.clickable
import androidx.compose.material3.*
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.NavController
import kotlinx.coroutines.launch
@Composable
fun CustomAppBar(
title: String,
backGroundColor: Color = Color.White,
actions: @Composable () -> Unit = { },
scaffoldState: ScaffoldState? = null, // Errors here...
navController: NavController,
) {
val scope = rememberCoroutineScope()
SmallTopAppBar(
title = {
Text(
title,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
colors …Run Code Online (Sandbox Code Playgroud) android material-components-android android-jetpack-compose android-jetpack-compose-material3
我正在使用 Room 库,并且在尝试构建应用程序时收到以下错误消息:
e: [kapt] An exception occurred: java.util.NoSuchElementException: Collection contains no element matching the predicate.
Run Code Online (Sandbox Code Playgroud)
这是更详细的错误消息:
FAILURE: Build failed with an exception
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Compilation error. See log for more details
Run Code Online (Sandbox Code Playgroud)
我将代码中的问题隔离在以下某处,尽管我不知道究竟是什么引发了此异常:
package com.example.pomoplay
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
@Database(entities = [(Category::class)], version = 1)
abstract class PomoPlayDatabase: RoomDatabase() {
abstract fun categoryDao(): CategoryDao
companion object {
private var INSTANCE: PomoPlayDatabase? = null
internal fun getDatabase(context: Context): PomoPlayDatabase? …Run Code Online (Sandbox Code Playgroud) 我有一个ActionBar菜单图标,可以打开一个CategoryFragment. 该片段接受从另一个片段传递的category对象SafeArgs参数。在CategoryFragment我保存category的姓名和身份证到分享的内容片段ViewModel作为SavedStateHandle值。我已经对其进行了设置,以便片段SavedStateHandle在需要时使用类别名称和 ID的存储值。例如,第一次CategoryFragment使用从发送片段传递的类别对象,但随后的创建CategoryFrgament将使用这些SavedStateHandle值。
问题是,如果在第一次打开CategoriesFragment然后通过按下手机的物理后退按钮或从导航CategoryFragment栏中手机的最近按钮终止应用程序后退出应用程序,现在通过按下 ActionBar 菜单图标直接打开显示一个空白屏幕。这是因为从返回的值SavedStateHandle是空的。我怎样才能解决这个问题?
类别片段
class CategoryFragment : Fragment(), SearchView.OnQueryTextListener {
lateinit var navController: NavController
private var adapter: TasksRecyclerAdapter? = null
private val viewModel: CategoryTasksViewModel by activityViewModels()
private var fromCategoriesFragment: Boolean = false
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the …Run Code Online (Sandbox Code Playgroud) android android-savedstate android-architecture-components android-safe-args
如何正确地将在 Visual Studio Code 中开发的现有 React 项目导入到 Visual Studio 2022 中?
我知道最新版本的 JavaScript (ES6) 现在支持创建类。我也明白在 ES5 和更早版本的 JS 中创建和使用对象的常用方法是创建对象原型。那么,使用类与如下所示的原型之间有什么区别,以及何时使用这两种方法?:
上课方式:
class Car {
constructor(brand) {
this.carname = brand;
}
present() {
return "I have a " + this.carname + ".";
}
}
mycar = new Car("Toyota");
document.getElementById("demo").innerHTML = mycar.present(); // outputs "I have a Toyota."
Run Code Online (Sandbox Code Playgroud)
原型方法:
function Person(first, last, age, eyecolor) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eyecolor;
}
//adding a new method to the prototype:
Person.prototype.name = function() {
return this.firstName + " " …Run Code Online (Sandbox Code Playgroud) 使用导航架构时,是否可以将片段标签名称显式分配给您导航到的片段,以便稍后在需要在返回堆栈上对它们执行某些操作时可以引用它们?我指的是这样的导航调用:NavController.navigate(R.id.exampleFragment)
如果不可能,那么NavController.navigate()添加到返回堆栈的片段的默认标签名称是什么?
android android-fragments android-navigation android-architecture-navigation
我有一个添加购物清单项目 Jetpack Compose 屏幕,其中包含多个TextField输入和底部的图像容器。屏幕在底部溢出并被切断。我怎样才能滚动屏幕?
android android-orientation android-scroll android-jetpack-compose
我在父组件中有一个表单,它将数据作为输入属性传输到子组件,而子组件有一个表单,可以读取此数据并使用此数据预填充其表单,作为编辑用户配置文件的方式。在我尝试使用传输的数据设置输入字段的行中,chrome 返回一个控制台错误,指出它无法读取未定义的 setValue 属性。代码可能有什么问题?
这是该代码:
this.eForm.setValue({
firstname: this.employee.user.firstname,
lastname: this.employee.user.lastname,
email: this.employee.user.email
});
Run Code Online (Sandbox Code Playgroud)
子组件:
import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { DataService } from 'src/app/services/data.service';
import { NgForm, ControlContainer } from '@angular/forms';
@Component({
selector: 'app-manager-view-employee-profile',
templateUrl: './manager-view-employee-profile.component.html',
styleUrls: ['./manager-view-employee-profile.component.css'],
viewProviders: [ { provide: ControlContainer, useExisting: NgForm } ]
})
export class ManagerViewEmployeeProfileComponent implements OnInit {
@ViewChild('f', {static: false}) eForm: NgForm;
@Input() employee: any;
constructor(private dataService: DataService) { }
ngOnInit() {
console.log(this.eForm);
console.log(this.employee.user.firstname);
this.eForm.setValue({
firstname: this.employee.user.firstname,
lastname: …Run Code Online (Sandbox Code Playgroud) android ×6
android-architecture-components ×1
android-architecture-navigation ×1
android-jetpack-compose-material3 ×1
android-room ×1
angular ×1
ecmascript-6 ×1
git-repo ×1
javascript ×1
kapt ×1
material-components-android ×1
reactjs ×1