我基本上为我的底部导航视图设置了 3 个片段,所有片段都链接到 activity.xml
activity.xml我放片段标签的地方。
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2"
app:navGraph="@navigation/my_nav"
android:layout_width="409dp"
android:layout_height="599dp" />
Run Code Online (Sandbox Code Playgroud)
我的 Activity.java 代码(特别是):
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
NavController navController = Navigation.findNavController(this, R.id.fragment);
NavigationUI.setupWithNavController(bottomNavigationView, navController);
Run Code Online (Sandbox Code Playgroud)
现在的问题是,如果我在 xml 中使用片段标记运行相同的 java 代码,它运行良好,但建议我使用<androidx.fragment.app.FragmentContainerView(linters)但在使用时<androidx.fragment.app.FragmentContainerView,它会在 Logcat 中显示错误。
Activity 没有设置 NavController
我在这个网站上看到了很多类似的错误和修复,比如FragmentContainerView as NavHostFragment
但是现在的问题是他们中的大多数人发布了 Kotlin 代码,而我尝试的少数 Java 代码对我不起作用
或者谁能将此代码翻译成java:
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
val navController = navHostFragment.navController
Run Code Online (Sandbox Code Playgroud) 这是我的第一篇 StackOverflow 帖子!
我在创建具有 pyzmq (v22.0.2) 依赖项的 pyinstaller(v4.2) 可执行文件时遇到问题。我通过运行“pyinstaller main.py”创建了一个可执行文件。dist 文件夹的创建没有错误,但是当我在终端中运行可执行文件时,我在下面的引号中看到错误。
我在 StackOverflow 和 pyinstaller 的文档中搜索了此类问题,但与我的确切问题不符。我看到提到一个 .spec 文件似乎是类似的问题,但我不确定这是否可行,因为我不清楚 pyzmq.libs\.load_order 是什么。
有谁知道如何克服这个错误或对我可以尝试的方法有很好的指导?
"C:\Users\[redacted path]\dist\main>main.exe
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "zmq\__init__.py", line 19, in <module>
File "zmq\__init__.py", line 13, in _delvewheel_init_patch_0_0_9
FileNotFoundError: [Errno 2] No such file or …Run Code Online (Sandbox Code Playgroud) 我有一个网络应用程序,用户可以通过表单输入创建多个 firestore 文档。我正在成功使用 batch.commit() 将这些对象添加到集合中。
arrayOfObjectsFromForm.forEach((object) => {
var docRef = db.collection("CollectionName").doc();
batch.set(docRef, object);
})
await batch.commit().then(() => {
console.log("committed batch write to firestore!")
return alert("success")
});
Run Code Online (Sandbox Code Playgroud)
但是,在batch.commit()成功后,如果用户再次填写表单以创建另一组要写入的文档,则会出现错误:调用commit()后,无法再使用写入批处理。有没有办法连续多次调用batch.commit()?我认为在 batch.commit() 之后返回一个值会“清理”该函数以再次使用它,但仍然出现错误。
javascript firebase google-cloud-platform google-cloud-firestore
android ×1
firebase ×1
java ×1
javascript ×1
navigation ×1
pyinstaller ×1
python ×1
python-3.x ×1
pyzmq ×1
zeromq ×1