在加载包含超过 6000 个项目的列表时,ConstraintLayout 与 RecyclerVIew (ListAdapter) 似乎会使用大量内存(高达 1GB)

2023-11-30

我正在为我的应用程序构建一个简单的 FileExplorer,并使用协程获取给定路径中的文件,并在显示它们时,内存使用量出现峰值。我在帖子底部显示了探查器工具选项卡。 我最好的猜测是,适配器正在为列表中的每个项目创建一个视图持有者,并且使用应用程序和设备本身的所有内存。

编辑:通过使用RelativeLayout而不是ConstraintLayout,它将内存使用量减少了3倍,并且显示列表需要几秒钟的时间。

内容快速摘要:

0 - 获取路径中内容的函数

1 - Android Studio 的运行控制台上出现 OutOfMemoryException 消息

2 - 垃圾收集器日志

3 - OOM 错误指向的代码片段

4 - 上面的代码片段被调用的地方

5 - ViewHolder代码

6 - 分析器屏幕截图显示最大峰值(超过 1GB)的概述

7 - 声明 RecyclerView 的 DialogFragment 布局文件

8 - 行

9 - 分析器工具中的选项卡显示 ConstraintLayout 调用和 onMeasure 及相关函数

10 - RecyclerView 和 ConstraintLayout 版本

实际获取文件的函数

private fun getFilesOnPath(path : String, showHiddenFiles : Boolean = false, onlyFolders : Boolean = false) : List<File> {
    val file = File(path)

    var listOfFiles = listOf<File>()

    try {
        listOfFiles = file.listFiles()
             .filter { showHiddenFiles || !it.name.startsWith(".") }
             .filter { !onlyFolders || it.isDirectory }.toList()
    } catch (exception : IllegalStateException) {
        Timber.tag(LOG_TAG).e("${exception.message} \n ${exception.cause}")
    } finally {
         return listOfFiles
    }

}

当我实现 ProgressBar 并在适当的时间显示它们时,会出现“beforeMain”和“afterMain”

我注意到,在文件较少的文件夹上,UI 不会滞后,直到加载文件列表,但是当单击这个特别大的 WhatsApp 文件夹时,应用程序将耗尽内存,并在控制台上显示此信息(PS:此错误与项目列表无关,它被加载和过滤就好了):

at java.lang.Throwable.nativeFillInStackTrace(Native method)
        at java.lang.Throwable.fillInStackTrace(Throwable.java:775)
        at java.lang.Throwable.<init>(Throwable.java:258)
        at java.lang.Error.<init>(Error.java:70)
        at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:53)
        at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:58)
        at java.lang.reflect.Constructor.newInstance0(Native method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:686)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:829)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:531)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
        at goldengentleman.goldennotebook.adapters.FileExplorerAdapter$FilesViewHolder$Companion.from(FileExplorerAdapter.kt:153)
        at goldengentleman.goldennotebook.adapters.FileExplorerAdapter.onCreateViewHolder(FileExplorerAdapter.kt:52)
        at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7201)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6332)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6216)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6212)
        at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2314)
        at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1631)
        at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
        at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4215)
        at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3615)
        at android.view.View.measure(View.java:24967)
        at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:736)
        at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measure(BasicMeasure.java:399)
        at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.measureChildren(BasicMeasure.java:105)
        at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:232)
        at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:113)
        at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1480)
        at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1555)
        at android.view.View.measure(View.java:24967)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7134)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:24967)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7134)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:24967)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7134)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at com.android.internal.policy.DecorView.onMeasure(DecorView.java:992)
        at android.view.View.measure(View.java:24967)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3270)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2001)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2300)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1861)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8478)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
        at android.view.Choreographer.doCallbacks(Choreographer.java:761)
        at android.view.Choreographer.doFrame(Choreographer.java:696)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7045)
        at java.lang.reflect.Method.invoke(Native method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

控制台上有明显的垃圾收集器日志:

I/nnotebook.debu: Clamp target GC heap from 216MB to 192MB
    Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 192MB/192MB, paused 145us total 826.488ms

问题可能是一个可笑的大列表,实际上有 6000 个项目,但该错误使得问题看起来像是在适配器上,这就是控制台指向的位置:

companion object {
     fun from(parent : ViewGroup) : FilesViewHolder = FilesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_file_explorer_file, parent, false))
}

以及调用上述函数的地方:

override fun onCreateViewHolder(parent : ViewGroup, viewType : Int) : RecyclerView.ViewHolder = when (viewType) {
        MODE_FOLDERS -> FoldersViewHolder.from(parent)
        MODE_FILES -> FilesViewHolder.from(parent)
        else -> FilesViewHolder.from(parent)
    }

编辑: 这是 ViewHolder 类(PS:不要试图理解 onClick 和 onClickListeners,它只是多选的逻辑):


    class FilesViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView) {

        private val fileName : TextView = itemView.findViewById(R.id.file_name_textView)
        private val fileIcon : ImageView = itemView.findViewById(R.id.file_icon_imageView)
        private val fileFormat : TextView = itemView.findViewById(R.id.file_format_textView)
        private val fileSize : TextView = itemView.findViewById(R.id.file_size_textView)
        private val fileTimeCreated : TextView = itemView.findViewById(R.id.time_created_textView)
        private val root : ConstraintLayout = itemView.findViewById(R.id.root)

        fun bind(item : FileModel, context : Context, adapter : FileExplorerAdapter) {

            if (item.fileType == FileType.FOLDER) {
                fileName.text = item.name
                fileIcon.setImageDrawable(context.getDrawable(R.drawable.folder_icon))
                fileSize.visibility = View.INVISIBLE
                fileTimeCreated.visibility = View.INVISIBLE
                fileFormat.visibility = View.INVISIBLE
                root.setBackgroundResource(R.drawable.border_square)
            } else {
                fileSize.visibility = View.VISIBLE
                fileTimeCreated.visibility = View.VISIBLE
                fileFormat.visibility = View.VISIBLE
                fileName.text = item.name
                fileFormat.text = item.extension
                fileSize.text = item.sizeInMB
                fileTimeCreated.text = Time.convertUnixToDateTime(item.timeCreated)
                val ext = item.extension
                fileIcon.apply {
                    setImageDrawable(context.getDrawable(
                        if (item.fileType == FileType.FOLDER) R.drawable.folder_icon
                        else if (ext == "pdf") R.drawable.pdf_box
                        else if (ext == "doc" || ext == "docx") R.drawable.file_word
                        else if (ext == "mp3" || ext == "3gp") R.drawable.music
                        else if (ext == "mp4" || ext == "webm") R.drawable.video
                        else if (ext == "jpg" || ext == "png") R.drawable.image
                        else R.drawable.file))
                }
                if (item in adapter.selectedFiles) {
                    root.setBackgroundResource(R.drawable.border_square_selected)
                } else {
                    root.setBackgroundResource(R.drawable.border_square)
                }
            }

            root.setOnClickListener {
               // Does multi-selection stuff like changing the rows background
            }

            root.setOnLongClickListener {
                // does the same as the above onClickListener
                true
            }

        }

        companion object {
            fun from(parent : ViewGroup) : FilesViewHolder = FilesViewHolder(
                LayoutInflater.from(parent.context).inflate(R.layout.row_file_explorer_file, parent, false))
        }
    }

这是 Profiler 在其最大峰值期间的情况:

Ridiculously large spike in memory usage

这个js在dialogfragment布局文件中声明了recyclerView:

<?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:layout_width = "match_parent"
    android:layout_height = "match_parent"
    android:background = "@drawable/dialog_fullscreen_background">

    <com.google.android.material.appbar.AppBarLayout
        android:id = "@+id/appBarLayout"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:elevation = "12dp"
        app:layout_constraintEnd_toEndOf = "parent"
        app:layout_constraintStart_toStartOf = "parent"
        app:layout_constraintTop_toTopOf = "parent">

        <androidx.appcompat.widget.Toolbar
            android:id = "@+id/toolbar"
            android:layout_width = "match_parent"
            android:layout_height = "?attr/actionBarSize"
            android:background = "?attr/toolbar_bottom_nav_color"
            android:paddingStart = "6dp"
            android:paddingEnd = "16dp"
            android:elevation = "@dimen/toolbar_nav_elevation"
            app:subtitleTextColor = "?attr/secondary_text_color"
            app:titleTextColor = "?attr/primary_text_color"
            app:contentInsetStartWithNavigation = "0dp"
            app:navigationIcon = "@drawable/close_x"
            tools:title = "@string/internal_storage" />
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id = "@+id/recyclerView"
        android:layout_width = "match_parent"
        android:layout_height = "0dp"
        app:layoutManager = "androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toTopOf = "@+id/_constraintLayout2"
        app:layout_constraintEnd_toEndOf = "parent"
        app:layout_constraintStart_toStartOf = "parent"
        app:layout_constraintTop_toBottomOf = "@+id/appBarLayout"
        tools:listitem = "@layout/row_file_explorer" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id = "@+id/_constraintLayout2"
        android:layout_width = "match_parent"
        android:layout_height = "64dp"
        android:background = "?attr/toolbar_bottom_nav_color"
        android:elevation = "@dimen/toolbar_nav_elevation"
        app:layout_constraintBottom_toBottomOf = "parent"
        app:layout_constraintEnd_toEndOf = "parent"
        app:layout_constraintHorizontal_bias = "0.0"
        app:layout_constraintStart_toStartOf = "parent">

        <Button
            android:id = "@+id/save_button"
            style = "@style/dialogButtonStyle"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_marginEnd = "8dp"
            android:text = "@string/save"
            app:layout_constraintBottom_toBottomOf = "parent"
            app:layout_constraintEnd_toEndOf = "parent"
            app:layout_constraintTop_toTopOf = "parent" />

        <Button
            android:id = "@+id/cancel_button"
            style = "@style/dialogButtonStyle"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_marginEnd = "8dp"
            android:text = "@string/cancel"
            app:layout_constraintBottom_toBottomOf = "parent"
            app:layout_constraintEnd_toStartOf = "@+id/save_button"
            app:layout_constraintTop_toTopOf = "parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

还有这一行:

<?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/root"
    android:layout_width = "match_parent"
    android:layout_height = "75dp"
    android:background = "@drawable/border_square"
    android:foreground = "@drawable/custom_ripple_no_border">

    <TextView
        android:id = "@+id/file_name_textView"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "16dp"
        android:ellipsize = "start"
        android:singleLine = "true"
        android:textColor = "?attr/primary_text_color"
        android:textSize = "20sp"
        app:layout_constraintBottom_toBottomOf = "@+id/file_icon_imageView"
        app:layout_constraintStart_toEndOf = "@+id/file_icon_imageView"
        app:layout_constraintTop_toTopOf = "@+id/file_icon_imageView"
        tools:text = "File file file" />

    <ImageView
        android:id = "@+id/file_icon_imageView"
        android:layout_width = "50dp"
        android:layout_height = "50dp"
        android:layout_marginStart = "16dp"
        android:layout_marginTop = "16dp"
        android:layout_marginBottom = "16dp"
        android:tint = "?attr/primary_text_color"
        app:layout_constraintBottom_toBottomOf = "parent"
        app:layout_constraintStart_toStartOf = "parent"
        app:layout_constraintTop_toTopOf = "parent"
        app:srcCompat = "@drawable/folder_icon"
        tools:ignore = "ContentDescription" />

    <TextView
        android:id = "@+id/file_format_textView"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "8dp"
        android:layout_marginBottom = "8dp"
        android:textColor = "?attr/secondary_text_color"
        android:textSize = "12sp"
        app:layout_constraintBottom_toBottomOf = "parent"
        app:layout_constraintEnd_toEndOf = "parent"
        tools:text = "Image File" />

    <TextView
        android:id = "@+id/file_size_textView"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:layout_marginTop = "8dp"
        android:layout_marginEnd = "8dp"
        android:textColor = "?attr/secondary_text_color"
        android:textSize = "12sp"
        app:layout_constraintEnd_toEndOf = "parent"
        app:layout_constraintTop_toTopOf = "parent"
        tools:text = "100KB" />

    <TextView
        android:id = "@+id/time_created_textView"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:layout_marginTop = "4dp"
        android:textColor = "?attr/secondary_text_color"
        android:textSize = "12sp"
        app:layout_constraintBottom_toBottomOf = "parent"
        app:layout_constraintStart_toStartOf = "@+id/file_name_textView"
        app:layout_constraintTop_toBottomOf = "@+id/file_name_textView"
        tools:text = "25/08/2000" />

</androidx.constraintlayout.widget.ConstraintLayout

现在,对于探查器工具选项卡。 它显示了很多似乎与 ConstraintLayout 相关的内容,例如:

AppHeap

Biggest class in ShallowSize and TotalCount

还有很多其他的也基本上显示了相同的,很多很多调用 onMeasure 和相关的 ui 函数。

app/buildgradle 上的 RecyclerView 和 ConstraintLayout 版本

// ConstraintLayout
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'

// RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'

显然,“错误”一直在 ConstraintLayout 库中。我的版本:

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'

显然,2.0.0-beta7 版本已经解决了某种内存泄漏问题。不幸的是,我的 AndroidStudio 根本没有告诉我有更新。 非常感谢@YuriyMysochenko 发现了它,以及那些试图帮助我的人!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在加载包含超过 6000 个项目的列表时,ConstraintLayout 与 RecyclerVIew (ListAdapter) 似乎会使用大量内存(高达 1GB) 的相关文章

  • 如何在 Android 中更改 Drawable 的颜色?

    我正在开发一个 Android 应用程序 并且我有一个从源图像加载的可绘制对象 在此图像上 我想将所有白色像素转换为不同的颜色 例如蓝色 然后缓存生成的 Drawable 对象 以便稍后使用它 举例来说 假设我有一个 20x20 PNG 文
  • 如何在应用程序关闭时在 Android 通知中显示操作按钮?

    我有一个安卓应用程序 对于通知 我们必须显示一些操作按钮 当应用程序打开时 我们可以自由地构建通知并显示操作按钮 但是当应用程序关闭时 通知会在 Android 的通知托盘中收到 应用程序开发人员无法控制构建用户界面和操作按钮 我们现在如何
  • Android:初始化本机 AudioRecord 对象时 AudioRecord 错误代码 -20

    Android 我想从麦克风读取缓冲区 以便我可以对其执行处理 以下是我的代码 int sampleRateInHz 8000 44100 22050 and 11025 int channelConfig AudioFormat CHAN
  • 在 ChromeO 上安装未知来源的 apk

    我今天早上更新了我的 Chromebook Asus Flip 以获取 Play 商店 我的 Chromebook 安装了 M53dev 通道版本 它运作良好 我可以安装并运行从 Play 商店下载的 Android 应用程序 我想测试我的
  • 如何通过我的活动在 Android 中设置铃声?

    我正在尝试找到一种方法来通过 Android 活动中的代码设置新的默认铃声 我已经将铃声下载到bytearray 最后 我设法将默认铃声设置为我下载的铃声 下面不包含下载代码 仅包含将其设置为默认铃声所需的代码 File k new Fil
  • Android 中的列表(特别是 RecyclerView 和 CardView)如何工作

    请原谅我问这个问题 但我是 Android 开发新手 尽管我正在尝试了解developer android com 网站上的基础知识 但大多数示例 即使他们说它们是为 Android Studio 构建的 尚未设置为使用 Gradle 因此
  • 当路径的点超出视野时,Android Canvas 不会绘制路径

    我在绘制路径时遇到了 Android Canvas 的一些问题 我的情况是 我有一个相对布局工作 如地图视图 不使用 google api 或类似的东西 我必须在该视图上绘制一条路径 canvas drawPath polyPath bor
  • 退出设备上的 system.img

    我正在为我们部署给客户的设备 LG p509 Optimus 1 开发自动应用程序更新解决方案 我们可以控制这些设备 并且目前在它们上安装自定义内核 但不是完整的自定义 ROM 由于我们试图在设备上自动更新我们的应用程序 因此我们需要由我们
  • 如何禁用操作栏上“向上”按钮的翻转?

    背景 我做了一个 应用程序管理器 https play google com store apps details id com lb app manager 替代应用程序 我希望添加 RTL 从右到左 语言的翻译 因为我知道在某些 And
  • Android 中 localTime 和 localDate 的替代类有哪些? [复制]

    这个问题在这里已经有答案了 我想使用从 android API 获得的长值 该值将日期返回为长值 表示为自纪元以来的毫秒数 我需要使用像 isBefore plusDays isAfter 这样的方法 Cursor managedCurso
  • 选项卡主机内的 Android Fragment 视图状态 [重复]

    这个问题在这里已经有答案了 可能的重复 使用 Fragment 为 Android 中的每个选项卡单独的返回堆栈 https stackoverflow com questions 6987334 separate back stack f
  • 是否可以通过 Android 应用程序来录音?

    我是一名开发人员 希望创建一个 Android 应用程序来记录电话 这是出于我个人的需要 为了我自己的目的和记录而记录电话 是否有可能做到这一点 是否可以访问麦克风以及通过扬声器发出的声音 我对 Android 开发有点陌生 所以请耐心等待
  • 如何为我的 Android Market APK 创建证书?

    我想将我的第一个 APK 应用程序上传到 Android Market 但我收到了此错误 顺便说一下 在 stackoverflow 中搜索时并没有引导我找到正确的链接 市场不接受使用调试证书签名的 APK 创建有效期至少 50 年的新证书
  • Android 中的库可以有自己的意图过滤器吗?

    我想开发一个可以包含在其他 Android 应用程序中的库来拦截某些类型的意图 是否可以 我创建了一个库和一个测试项目 两者都有自己的AndroidManifest xml文件 在库的清单中 我为操作 TEST 定义了一个意图过滤器 但是
  • 哪个视图最亮?

    在Android中 哪个是轻量级视图 例如 View Textview Edittext 等 在某些情况下 我们需要使用视图来填充区域而不向用户显示视图 同时屏幕加载速度应该很快 您可以使用空间 android widget Space S
  • 如何运行 Kotlin REPL kotlinc-jvm 或 kotlinc

    我对 Kotlin 完全陌生 我正在尝试运行 Kotlin REPL 下列的this https kotlinlang org docs tutorials command line html running the repl 考虑到我使用
  • 禁用 Android 菜单组

    我尝试使用以下代码禁用菜单组 但它不起作用 菜单项仍然启用 你能告诉我出了什么问题吗 资源 菜单 menu xml menu menu
  • 检查应用程序是否在 Android Market 上可用

    给定 Android 应用程序 ID 包名称 如何以编程方式检查该应用程序是否在 Android Market 上可用 例如 com rovio angrybirds 可用 而 com random app ibuilt 不可用 我计划从
  • LifeCycleAware Fragment 中的片段生命周期事件

    我有一个生命周期感知片段和一个LifecycleObserver class public class MyFragment extends Fragment Override public void onCreate Nullable B
  • Android GetPTLAFormat 上的 Phonegap 错误

    我们正在开发一个使用 jQuery 移动和电话间隙的应用程序 一切似乎都工作正常 但是当在连接的 Android 手机上运行应用程序时 我们在 Eclipse logcat 中看到大量类似这样的错误 0 GetPTLAFormat inva

随机推荐

  • 如何将 REST API 限制为用户特定的内容

    我使用 PassportJS 在 MEAN 堆栈上设置了相当简单的 API 我在设置没有安全性 获取一般数据 和用户身份验证 安全信息 的路由时没有任何问题 但是 我似乎找不到授予基于用户的访问权限的最佳实践 例如 api users id
  • 如何防止提供扩展方法的公共类出现在 Intellisense 中?

    有没有办法从 Intellisense 中 隐藏 类的名称 该类的唯一目的是提供扩展方法 我想从 Intellisense 列表中删除类名 但需要该类的扩展方法可以通过 Intellisense 以通常的方式供外部程序集使用 我希望您可以使
  • 模板中的模板:为什么嵌套模板参数列表中的“`>>”应该是“> >””

    我知道当我们在另一个模板中使用模板时 我们应该这样写 vector
  • 使用 CSS 定位某些单词?

    这是一个理论问题 但我想知道这是否可能 所以如果你有一个 div 包含一些内容 例如 div 100 00 BUY div 那么您可以定位 100 00 英镑 而不定位其余部分吗 那么你可以增加 100 00 英镑的字体大小吗 不 如果不将
  • 如何使用 Angular 2 在下拉列表中仅显示唯一值

    我有一个 JSON 数据 我使用 ngFor 将 accountNumber 显示到下拉列表中 由于 JSON 数据中有多个条目具有相同的帐号 因此我在下拉列表中多次看到相同的帐号 在此输入图像描述 html div class btn b
  • Phonegap / Cordova - 构建 Apk

    有谁知道如何生成apk吗 我正在尝试使用 Phonegap Cordova CLI 构建我的应用程序的 apk 我需要一些有关它的教程或信息 要检查是否已安装构建 APK 所需的所有内容 请首先运行以下命令 cordova requirem
  • getjson jquery 解析数组

    得到简化的阵列工作见下文 后续要解析的复杂数组请参阅here TLDR 想要从数组中获取每个标题并将其插入到 div 中 而不知道使用 Jquery getJSON 中的内容 Edit 数据来自一个软件 该软件每隔几秒就使用新数据输出 JS
  • 在 view-file.blade.php 中找不到类“Form”

    我正在尝试在视图文件中渲染文本输入字段 我不断收到此错误 在 view file blade php 中找不到类 form 模板 extends layouts app section content h1 New h1 Form open
  • bootstrap jquery show.bs.modal 事件不会触发

    我正在使用 bootstrap 3 文档中的模态示例 模态有效 但是我需要在 show bs modal 事件触发时访问它 现在我只是在尝试 myModal on show bs modal function alert hi 什么也没发生
  • 从 JS 中被拒绝的 Promise 中恢复

    我 大部分 使用本机承诺并尝试从错误中恢复并继续执行承诺链 实际上 我正在这样做 REST 查询以查看 ID 是否存在 请注意 这会返回一个延迟的 jquery then 成功表示ID存在 失败则停止 失败说明ID不存在 继续创建ID th
  • C#:C# 中是否有 Java 中的 TimerTask 的等效类?

    我正在寻找 C 中 Java 中是否有等效的 TimerTask 类 这里引用了Java的TimerTask http download oracle com javase 1 4 2 docs api java util TimerTas
  • CUDA纹理线性过滤

    在 CUDA C 编程指南第 5 版附录 E 2 线性滤波 中 指出 在这种过滤模式下 仅适用于浮点 纹理 纹理获取返回的值是 粗体部分让我感到困惑 做floating point仅指纹素类型 还是也指返回类型 例如 我声明了 3 个纹理
  • 如何使用谷歌翻译翻译整个网站

    我目前正在使用以下内容来翻译网页 http translate google com about intl en ALL tour html professional 问题是 当我将 Google 网站上生成的代码片段放到我的网页上时 用户
  • 创建可能案例的简单方法

    我有数据列表 例如 a 1 2 3 4 b a b c d e c 001 002 003 我想创建另一个新的列表 该列表由 a b c 的所有可能情况混合而成 如下所示 d 1a001 1a002 1a003 4e003 是否有任何模块或
  • 是否总是需要条件注释?

    在创建了一些网络应用程序之后 我真的认为一段时间后处理条件注释就不那么有趣了 对于这个问题有什么计划吗 处理不同的浏览器会更复杂还是更容易 某种形式的功能嗅探总是需要的 但希望将来这可以更多地基于更良性的脚本化对象嗅探形式 从而实现渐进增强
  • 如何比较两个日期时间字符串并返回小时数差异? (bash外壳)

    我可以使用以下代码在 php 中做到这一点 dt1 2011 11 11 11 11 11 t1 strtotime dt1 dt2 date Y m d H 00 00 t2 strtotime dt2 tDiff t2 t1 hDiff
  • 禁用鼠标中键单击

    我需要您帮助解决一个问题 即如何禁用鼠标中键单击任何链接以在 IE 7 8 9 中打开新选项卡 我尝试过很多类似的事情 return false e cancelBubble true e returnValue false 但无法阻止 I
  • 当一个 @Controller 扩展另一个 @Controller 时,“发现不明确的映射”

    我有一个ImportAction类 用作多个特定于类型的导入控制器的父类 例如ImportClientsAction and ImportServicesAction ImportAction是一个带有注释的 Spring MVC Cont
  • 无法加载资源:服务器响应状态为 409

    自动 WordPress 更新后 插件表单 联系表单 7 现在在其下方显示斜杠 并且不再触发 wpcf7mailsent 侦听器事件 因此在提交表单后不再将其重定向到感谢页面 此错误 服务器响应状态为 409 或也称为 net ERR AB
  • 在加载包含超过 6000 个项目的列表时,ConstraintLayout 与 RecyclerVIew (ListAdapter) 似乎会使用大量内存(高达 1GB)

    我正在为我的应用程序构建一个简单的 FileExplorer 并使用协程获取给定路径中的文件 并在显示它们时 内存使用量出现峰值 我在帖子底部显示了探查器工具选项卡 我最好的猜测是 适配器正在为列表中的每个项目创建一个视图持有者 并且使用应