在加载包含超过 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短音的正确播放方法?

    我正在创建一个应用程序 屏幕上将有多个图像 这些图像将是按钮 点击时会播放短促的声音 我对此进行了研究 只能找到我当前用来播放声音的方法 这似乎根本没有响应 我希望声音能够快速播放并且能够响应多次快速点击 我不确定这在 Android 中是
  • Xamarin Android Webview Javascript

    我正在尝试通过 Xamarin for Android 创建一个移动应用程序 它有一个显示网站的 WebView 问题是正常按钮会触发 但 javascript 事件不会触发 我已经启用了 Javascript 但没有运气 如何在 Andr
  • AdapterContextMenuInfo 始终为 null

    我尝试通过 android 开发文档中的书来做到这一点 this didn t create a menu i don t know why registerForContextMenu getListView setListAdapter
  • 按下按钮时应用不同的样式

    有没有办法在按下按钮时将样式应用于按钮 如果我有一种风格样式 xml
  • Android Q:file.mkdirs() 返回 false

    我们有一个应用程序 使用外部存储来存储一些临时文件 图像 二进制数据 该代码已经运行了几年 直到最近才发生重大变化 在 Android Q 上它不起作用 File f new File Environment getExternalStor
  • 如何在 Linux 内核中定义并触发我自己的新软中断?

    我想在 Linux 内核中创建自己的软中断 这是正确的方法吗 In the init我想触发该模块的softirq我将添加一个调用 394 void open softirq int nr void action struct softir
  • Android应用程序组件销毁和重新创建的详细信息

    有人可以向我提供一些具体的 值得信赖的 最好是简洁的 信息 内容如下 系统销毁和 如果适用 重新创建组件的顺序 片段 活动 活动的线程 异步任务 计时器 静态数据 类何时卸载 其他类中的线程 异步任务 定时器 主机 TabActivity
  • java.lang.IllegalStateException:应用程序 PagerAdapter 更改了适配器的内容,而没有调用 PagerAdapter#notifyDataSetChanged android

    我正在尝试使用静态类将值传递给视图 而不是使用意图 因为我必须传递大量数据 有时我会收到此错误 但无法找出主要原因是什么 Error java lang IllegalStateException The application s Pag
  • 为什么是 javascript:history.go(-1);无法在移动设备上工作?

    首先 一些背景 我有一个向用户呈现搜索页面 html 表单 的应用程序 填写标准并单击 搜索 按钮后 结果将显示在标准部分下方 在结果列表中 您可以通过单击将您带到新页面的链接来查看单个结果的详细信息 在详细信息页面中 我添加了一个 返回结
  • 图像作为电子邮件附件

    我想构建一个应用程序 我可以在电子邮件中附加图像 打开图像并将其设置为我的壁纸 我想让它跨平台 所以你能告诉我是否可以使用phonegap 或者我是否必须为iphone和android构建一个本机应用程序 您好 如果您只想通过电子邮件附加图
  • 从 BroadcastReceiver 类调用活动方法

    我知道我可以做一个内部接收器类来调用接收器中的任何方法 但我的主要活动太大了 要做的事情也很多 因此 我需要一个扩展广播接收器的类 但它不是内部类 并且可以从我的主要活动中调用一种方法 我不知道是否可能 但我的活动是家庭活动和 single
  • 对于一个单元格,RecyclerView onBindViewHolder 调用次数过多

    我正在将 RecyclerView 与 GridLayoutManager 一起使用 对于网格中的每个项目 我需要调用 REST api 来检索数据 然后 从远程异步获取数据后 我使用 UIL 加载 显示图像 一切似乎都很好 但我发现 on
  • logcat 中 mSecurityInputMethodService 为 null

    我写了一点android应显示智能手机当前位置 最后已知位置 的应用程序 尽管我复制了示例代码 并尝试了其他几种解决方案 但似乎每次都有相同的错误 我的应用程序由一个按钮组成 按下按钮应该log经度和纬度 但仅对数 mSecurityInp
  • Android 中如何通过彩信发送图片?

    我正在开发多媒体应用程序 我正在通过相机捕获一张图像 并希望将该图像和文本发送到其他号码 但我不知道如何通过彩信发送图像 MMS 只是一个 http post 请求 您应该使用执行请求额外的网络功能 final ConnectivityMa
  • 我应该释放或重置 MediaPlayer 吗?

    我有自己的自定义适配器类 称为 WordAdapter 并且我正在使用媒体播放器 名为pronounce WordAdapter 类中的全局变量 我有不同的活动 其中每个列表项都有线性布局 名为linearLayout 我正在设置onCli
  • 如何在 Android 中从 WorkManager 取消工作?

    我已经保存了 WorkManagerUUID转换成String在领域数据库中 这是代码 Constraints constraints new Constraints Builder setRequiredNetworkType Netwo
  • 您使用什么物理 Android 设备进行测试?

    有什么好的推荐用于测试目的的物理 Android 设备吗 我正在苹果阵营寻找像 iPod touch 这样的设备 可以帮助 iOS 开发人员测试他们的东西 我知道有 Nexus One 但那东西相当昂贵 而且我并不真正关心手机的东西 而是可
  • Android 如何将总天数准确更改为年、月、日?

    我正在做一个应用程序 该应用程序与根据给定的生日日期输入获取一个人的年龄有关 为此 我从下面的代码中获取从该日期到当前日期的总天数 String strThatDay 1991 05 10 SimpleDateFormat formatte
  • 如何使用 AccessibilityService 在 Android 中模拟按键

    我正在编写一个辅助服务 我一直在尝试在应用程序上进行一些自动搜索 我使用accessibilityservice action paste来填充EditText 然后我需要模拟软键盘上的按键 但我不知道如何做 你们能帮我一下吗 你可以尝试A
  • 我的应用程序中的后退按钮出现问题[关闭]

    很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我想在手机关闭时清除共享首选项值 你

随机推荐

  • 如何将 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 并使用协程获取给定路径中的文件 并在显示它们时 内存使用量出现峰值 我在帖子底部显示了探查器工具选项卡 我最好的猜测是 适配器正在为列表中的每个项目创建一个视图持有者 并且使用应