小编Ari*_*erá的帖子

Jetpack Compose 中的 Surface 和 Card 有什么区别?

基本上是一样的吧?它们具有相同的属性。我真的不知道什么时候必须使用每一个。

从技术上讲,Cards 用于卡片视图,但 Surface 具有相同的属性,如elevationborder

android android-jetpack-compose android-compose-card android-jetpack-compose-surface

16
推荐指数
2
解决办法
5629
查看次数

在Intent片段上获取Serializable ArrayList

在我的片段上,我想得到ArrayList<Animal>.我创建了一个newInstance函数.

  companion object {
    private val ARG_TITLE = "ARG_TITLE"
    private val ARG_ANIMALS = "ARG_ANIMALS"

    fun newInstance(title: String,animals: ArrayList<Animal>): ExampleFragment{
        val fragment = ExampleFragment()
        val args = Bundle()
        args.putString(ARG_TITLE, title)
        args.putSerializable(ARG_ANIMALS, animals)
        fragment.arguments = args
        return fragment
    }
}
Run Code Online (Sandbox Code Playgroud)

在我身上onCreate()我有这个.

 private var title: String = ""
lateinit private var animals:ArrayList<Animal>

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    if (arguments != null) {
        title = arguments.getString(ARG_TITLE)
        animals = arguments.getSerializable(ARG_ANIMALS)
    }
}
Run Code Online (Sandbox Code Playgroud)

必需:找到ArrayList序列化!

无法转换为ArrayList.

android fragment android-intent kotlin

13
推荐指数
1
解决办法
3806
查看次数

Playstore:我无法创建订阅

我只是想创建一个订阅。如果你阅读官方文档你会看到:

打开 Play 管理中心并转到订阅页面(获利 > 产品 > 订阅)。单击创建订阅

问题是我没有标签。我只有一个上传 APK 的按钮。

Play 商店创建订阅

android in-app-billing google-play-console

9
推荐指数
1
解决办法
1295
查看次数

保持Textinputlayout提示总是顶部

我的提示文本总是可以顶部,好像它是可聚焦的吗?

我试过这个:

 <android.support.design.widget.TextInputLayout
            android:id="@+id/etSurnameInput"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/llNameImage"
            android:hint="My Hint Text"
            app:hintEnabled="true"
            app:hintAnimationEnabled="false"
            android:textColorHint="@color/gray_title">
Run Code Online (Sandbox Code Playgroud)

android android-edittext textinputlayout

7
推荐指数
2
解决办法
2704
查看次数

UnitTest协程Kotlin用例MVP

我试图模拟我的用例的响应,该用例适用于协程。

fun getData() {
    view?.showLoading()
    getProductsUseCase.execute(this::onSuccessApi, this::onErrorApi)
}
Run Code Online (Sandbox Code Playgroud)

我的useCase已注入演示者。

GetProductsUseCase具有以下代码:

class GetProductsUseCase (private var productsRepository: ProductsRepository) : UseCase<MutableMap<String, Product>>() {

    override suspend fun executeUseCase(): MutableMap<String, Product> {
        val products =productsRepository.getProductsFromApi()
        return products
    }
}
Run Code Online (Sandbox Code Playgroud)

我的BaseUseCase

abstract class UseCase<T> {

    abstract suspend fun executeUseCase(): Any

    fun execute(
        onSuccess: (T) -> Unit,
        genericError: () -> Unit) {
        GlobalScope.launch {
            val result = async {
                try {
                    executeUseCase()
                } catch (e: Exception) {
                    GenericError()
                }
            }
            GlobalScope.launch(Dispatchers.Main) {
                when {
                    result.await() is GenericError …
Run Code Online (Sandbox Code Playgroud)

android unit-testing kotlin-coroutines

7
推荐指数
1
解决办法
101
查看次数

如何检查lottie动画是否有效?

我正在尝试用 Lottie 进行简单的加载。我找到了这个动画: https: //lottiefiles.com/18563-cooking#_= _

  <com.airbnb.lottie.LottieAnimationView
            android:id="@+id/animation_view"
            android:layout_width="200dp"
            android:layout_height="200dp"
            app:lottie_autoPlay="true"
            app:lottie_loop="true"
            app:lottie_rawRes="@raw/test"
            />
Run Code Online (Sandbox Code Playgroud)

它存储在 SRC/Main/res/raw 中,但我收到此错误:

您必须在加载图像之前设置图像文件夹。使用 LottieComposition#setImagesFolder 或 LottieDrawable#setImagesFolder 设置它

我尝试添加到资产文件夹app:lottie_fileName

所以我认为动画是错误的,因此我想知道是否存在一些工具或命令来知道动画是否有效。

android lottie

3
推荐指数
1
解决办法
6699
查看次数

打开UIViewController,不要显示UINavigationController导航栏

我的视图中有导航控制器.

在此输入图像描述

在我的View Controller中有一个didSelectRowAtIndexPath带开关的方法.在第一个单元格中,我想打开我的新视图"Empresa",我使用这个:

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("Empresa")
        self.presentViewController(vc, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

和工作,但不是apear导航控制器.像这样查看apear:

在此输入图像描述

iphone objective-c uinavigationcontroller ios swift

1
推荐指数
1
解决办法
351
查看次数