我正在尝试将Firebase Crashlytics集成到我的应用程序中,该应用程序启用了Firebase崩溃报告.我在这里遵循了文档,但是在运行自定义构建阶段时,我的构建总是失败:
"${PODS_ROOT}/Fabric/run"
Run Code Online (Sandbox Code Playgroud)
Xcode中的错误如下:
错误:结构:配置问题
Fabric API密钥无效.您的Fabric运行脚本构建阶段应包含您的API密钥:./ Fabric.framework/run INSERT_YOUR_API_KEY INSERT_YOUR_BUILD_SECRET
我没有Fabric API密钥,我认为它们的结构密钥应该由Firebase库来处理.我的项目中有Info.plist,Firebase功能齐全,但我无法通过Fabric运行阶段.任何有关如何解决这个问题的帮助非常感谢!
我正在尝试根据github 示例实现navigation controller
具有多个返回堆栈的多个BottomNavigationView
。但是,该示例为每个选项卡使用了不同的导航图,这使事情变得简单。在我的情况下,我需要对所有选项卡使用相同的导航图,但起始目的地与导航图中设置的“主页目的地”不同。
到目前为止,我已经设法修改NavigationExtensions
文件以实现所有选项卡的单个导航图,并且我获得了多个navControllers
带有自己的后堆栈的导航图,但我无法弄清楚如何在不同的目的地启动导航图。
我.navigate
在获取导航控制器时尝试使用,但由于它还没有连接,所以它不起作用。关于如何实现这一目标的任何想法?谢谢你。
android android-architecture-navigation android-jetpack-navigation
我正在构建一个应用程序,我正在尝试将一个 Fragment 显示为另一个 Fragment 的叠加层,我知道如何按照此问题进行操作。
但是,我正在使用 Android 导航组件,并且我试图弄清楚如何在导航到它时将片段显示为叠加层而不是替换当前可见的片段。有没有办法或者它仍然不受支持?
我是 docker 新手,我正在尝试开始永久安装 Rancher。要创建 docker 容器,我运行以下命令:
docker run -d --name rancher-server -p 8080:8080 rancher/server
请注意,我想将容器的 8080 端口转发到我主机的 8080,因为 80 被我主机上的 nginx 占用。
现在,当我停止上述容器并尝试使用它再次启动时,出现docker start <Container ID>
以下错误:
Error response from daemon: driver failed programming external connectivity on endpoint rancher-server (c18940f957ed1f737fd5453ea29755adea762d758643a64984d5e3ce8bd3fdbe): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
Error: failed to start containers: c93794a8c0ad
我知道这是因为 nginx 使用端口 80,所以我的问题是如何启动我现有的容器并告诉它转发它的端口?
运行docker start -d -p 8080:8080 c93794a8c0ad
给了我以下错误:unknown shorthand flag: 'd' in -d
那么如何启动一个带有转发端口的容器呢?谢谢!
我正在尝试在我的应用程序中实现 Facebook 登录,但我面临一个非常奇怪的问题,登录过程开始时,失败并显示一条非常神秘的消息,并且我的应用程序方面没有抛出任何异常,所以我不知道是什么继续。
我怀疑DialogFragment
我在登录过程中使用 a 与我有关,而 FacebookLoginButton
是其中的一部分,DialogFragment
而不是正常的片段或活动。我在我的 XML 中添加登录按钮:
<com.facebook.login.widget.LoginButton
android:id="@+id/loginFacebookButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin_double"
android:layout_marginEnd="@dimen/default_margin_double"
android:layout_marginBottom="@dimen/default_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:background="@drawable/rounded_blue_bg"
android:layout_marginTop="@dimen/default_margin"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="@dimen/default_margin_double"
app:layout_constraintBottom_toTopOf="@id/loginOrLayout" />
Run Code Online (Sandbox Code Playgroud)
我在代码中添加回调,在我的 onCreateDialog
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.FullscreenDialog)
val view = View.inflate(context, R.layout.fragment_login, null)
//FB Login callback manager
val callbackManager = CallbackManager.Factory.create()
val fbLoginButton = view.loginFacebookButton
fbLoginButton.fragment = this
fbLoginButton.setPermissions(listOf("name", "email", "public_profile"))
fbLoginButton.loginBehavior = LoginBehavior.NATIVE_WITH_FALLBACK
fbLoginButton.registerCallback(callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: …
Run Code Online (Sandbox Code Playgroud) android android-fragments facebook-login android-dialogfragment kotlin
我有一个 html 字符串,看起来像这样:
<body>
I am a text that needs to be wrapped in a div!
<div class=...>
...
</div>
...
I am more text that needs to be wrapped in a div!
...
</body>
Run Code Online (Sandbox Code Playgroud)
所以我需要将悬挂的 html 文本包装在它自己的 div 中,或者将整个正文(文本和其他 div)包装在顶级 div 中。有没有办法用 JSoup 来做到这一点?非常感谢!
我正在尝试使用ConstraintLayout
.
但是,这两个用户名TextViews
需要扩展直到达到最大宽度,这取决于每个手机的屏幕。
第一个用户名应该是可见的,尽可能多,它应该有一个 8dp 的边距,然后是具有固定宽度的“回复箭头”,然后,如果合适,尽可能多的“回复用户名”TextView
应该是可见的. 点分隔符、日期和喜欢的TexViews
应该是可见的,在wrap_content
.
在 iOS 中,我们已经通过使用内容拥抱和内容压缩阻力优先级来实现这样的布局。Android 中是否有类似的功能?
这是我的 XML 布局供参考:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/newspaperLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/commentDepthView"
android:layout_width="2dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/default_margin"
android:background="@color/blueDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/commentAuthorTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:ellipsize="end"
android:lines="1"
android:textColor="@color/blue"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/commentTextView"
app:layout_constraintEnd_toStartOf="@id/replyToArrowImageView"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/commentDepthView"
app:layout_constraintTop_toTopOf="parent"
tools:text="Username"/>
<ImageView
android:id="@+id/replyToArrowImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginEnd="8dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/commentAuthorTextView"
app:layout_constraintEnd_toStartOf="@id/commentReplyToTextView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/commentAuthorTextView"
app:layout_constraintTop_toTopOf="@id/commentAuthorTextView"
app:srcCompat="@drawable/reply_to_arrow"/>
<TextView
android:id="@+id/commentReplyToTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:ellipsize="end"
android:lines="1" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个自定义“警告”对话框,我希望其中有圆角。因此,我将整个布局放入 CardView 中,并将对话框的布局设置为此布局。
然而,在深色背景上,例如默认的 Android 对话框背景,我似乎在对话框的角落处出现了白色像素。
我已经尝试过这里建议的设置app:cardBackgroundColor="@color/transparent"
,但没有什么区别。
我的对话框的布局如下(与屏幕截图不同,但按钮、bakcground 和 CardView 是相同的):
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/error_cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/error_dialog_margin"
android:layout_marginEnd="@dimen/error_dialog_margin"
app:cardCornerRadius="@dimen/error_dialog_corner_radius"
app:cardElevation="@dimen/error_dialog_elevation"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/error_icon"
style="@style/ErrorViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_outer_margin"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/error_icon"
android:tint="@color/redColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/error_title"
style="@style/ErrorViewTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_outer_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginEnd="@dimen/default_outer_margin"
android:ellipsize="end"
android:gravity="center_horizontal"
android:maxLines="2"
android:text="@string/something_went_wrong" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/error_message"
style="@style/ErrorViewMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_outer_margin"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginEnd="@dimen/default_outer_margin"
android:gravity="center"
android:minHeight="55dp"
tools:text="@string/try_again_later" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin"
android:background="@color/blueColor">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/error_ok_button"
style="@style/PrimaryButton" …
Run Code Online (Sandbox Code Playgroud) 我是猫鼬新手,我正在尝试创建一个使用 OpenWeatherMap API 的应用程序。从 API 请求数据后,我将它们保存到我的 MongoDB 中,然后我想以 json 形式返回结果,因此我调用以下函数:
async function saveForecast(data) {
// Code here for creating the "forecastList" from the data and fetching the "savedLocation" from the DB
const newForecast = new Forecast({
_id: new mongoose.Types.ObjectId(),
location: savedLocation,
city: {
id: data.city.id,
name: data.city.name,
coordinates: data.city.coord,
country: data.city.country
},
forecasts: forecastList
});
try {
const savedForecast = await newForecast.save();
return savedForecast.populate('location').lean().exec(); //FIXME: The lean() here throws TypeError: savedForecast.populate(...).lean is not a function
} catch (err) {
console.log('Error …
Run Code Online (Sandbox Code Playgroud) 我有一个CoordinatorLayout
包含一个BottomNavigationView
和AppBarLayout
一个ToolBar
里面有一个的。(BottomNavigationView
不在 内AppBarLayout
,因为这样做会破坏 的位置BottomNavigationView
)。
我需要以编程方式显示/隐藏AppBarLayout
和BottomNavigationView
,当某些事件发生时(例如在片段上onResume
),到目前为止我已经管理设置appBarLayout.setExpanded(true, true)
以显示/隐藏 AppBar,但我不知道如何做相同BottomNavigationView
,因为它没有任何显示/隐藏自身的方法。
我的行为BottomNavigationView
是app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
,在布局 xml 中设置。如何在我的代码中获得对这种行为的引用以管理其展开/折叠状态?
我需要在我的navigationController的左侧为我的应用程序创建一个“汉堡菜单”按钮,但是由于NavCon是透明的,因此我的图标上需要有一个阴影。
因此,我创建了一个带有图像,阴影的自定义UIButton,并将其添加为UIBarButtonItem上的自定义视图,如下所示:
let menuButton = UIButton(type: .custom)
menuButton.addTarget(self, action: #selector(showSideMenu), for: .touchUpInside)
menuButton.setImage(#imageLiteral(resourceName: "menu_white"), for: .normal)
menuButton.tintColor = UIColor.white
menuButton.layer.masksToBounds = false
menuButton.layer.shadowColor = UIColor.black.cgColor
menuButton.layer.shadowOpacity = 1.0
menuButton.layer.shadowRadius = 5
menuButton.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: menuButton)
Run Code Online (Sandbox Code Playgroud)
上面的代码在iOS 11上运行良好,但是当我在ios 9和10(模拟器和真实设备)上测试我的应用程序时,菜单图标不可见。它是可单击的,并且按预期方式工作,但是没有可见的图标。
在View Hierarchy Debugger中,我可以看到宽度和高度为0的UIButton,而在ios 11中,我可以看到带有嵌入式UIButton的普通UIButtonBarStackview。
关于如何解决此问题以及为什么会发生的任何想法?非常感谢你!
我在 Swift 中有一段代码,可以将TVSchedule
对象列表减少为TVMatch
pobjects数组。每个 TVSchedule 都有一个名为 events 的属性,即一个TVMatch
es列表。
swift中的代码如下:
var matches: [TVMatch] {
let slots = timeSlots.reduce(into: [TVMatch]()) { (result, schedule) in
result.append(contentsOf: schedule.events)
}
return slots
}
Run Code Online (Sandbox Code Playgroud)
我试图在 Kotlin 中做同样的缩减,我的代码如下:
val matches: ArrayList<TVMatch>
get() {
val slots = timeSlots.fold(arrayListOf<TVMatch>()) { result, schedule ->
result.addAll(schedule.events)
}
return slots
}
Run Code Online (Sandbox Code Playgroud)
但是,Kotlin 代码给了我一个类型错误,并且无法编译。这里有什么问题?