RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-260752

Ivan Petrov's questions

Martin Hope
Ivan Petrov
Asked: 2020-05-07 03:48:09 +0000 UTC

RecyclerView 不显示自定义视图

  • 3

有问题RecyclerView,我在 Google 中找不到解决方案。里面有一个片段RecyclerView。元素被生成但不被渲染。

片段类 - https://github.com/LazyTechwork/QRScanner/blob/master/app/src/main/java/ru/lazytechwork/qrscanner/fragments/HistoryFragment.kt

class HistoryFragment : Fragment() {
    private var scans: List<Scan> = emptyList()
    private val ioScope = CoroutineScope(Dispatchers.IO)
    private lateinit var recyclerView: RecyclerView
    private lateinit var viewAdapter: ScanHistoryAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_history, container, false)

        viewAdapter = ScanHistoryAdapter(scans, (activity as MainActivity).db)
        recyclerView = view.findViewById<RecyclerView>(R.id.scanlist).apply {
            setHasFixedSize(true)
            adapter = viewAdapter
        }

        ioScope.launch {
            scans = (activity as MainActivity).getScans()
            viewAdapter.updateDataset(scans)
        }
        return view
    }

}

片段 XML - https://github.com/LazyTechwork/QRScanner/blob/master/app/src/main/res/layout/fragment_history.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:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/scanlist"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:scrollbars="vertical"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constrainedHeight="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:listitem="@layout/history_item" />
</androidx.constraintlayout.widget.ConstraintLayout>

适配器代码 - https://github.com/LazyTechwork/QRScanner/blob/master/app/src/main/java/ru/lazytechwork/qrscanner/data/adapters/ScanHistoryAdapter.kt

class ScanHistoryAdapter(private var dataset: List<Scan>, private val db: AppDatabase) :
    RecyclerView.Adapter<ScanHistoryAdapter.ViewHolder>() {
    class ViewHolder(val historyItem: HistoryItem) : RecyclerView.ViewHolder(historyItem)

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ViewHolder =
        ViewHolder(HistoryItem(parent, db))


    fun updateDataset(scans: List<Scan>) {
        dataset = scans
        notifyDataSetChanged()
    }

    override fun getItemCount(): Int = dataset.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val viewItem = holder.historyItem
        val scan = dataset[position]
        viewItem.setScan(scan)
    }
}

在 Android Studio 中一切正常。

安卓应用截图 安卓工作室屏幕

android
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-04-12 20:13:53 +0000 UTC

在 typeahead.js 中选择后无法清除输入

  • 0

选择typeahead.js中的元素后清除表单时出现问题。我附上了事件监听器代码:

.on('typeahead:select', function (e, datum) {
    console.log($(this));
    $(this).val('');
    e.preventDefault();
})

有什么问题?通过开发者控制台,一切都被悄悄地清理干净。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-03-17 00:03:03 +0000 UTC

属于ToMany(多对多)不起作用

  • 0

有一个数据透视表championship_user:

桌子

我得到这样的Championship用户数据User:

public function championships()
    {
        return $this->belongsToMany(Championship::class)->withPivot('skill_id', 'role', 'result');
    }

在控制器中,我需要获取所有Championship用户:

$championships = Auth::user()->championships();
        $skills = Skill::all();
        dd($championships);

结论dd()是:

#related: Championship {#236 ▼
    #hidden: []
    #guarded: []
    #connection: "mysql"
    #table: null
    #primaryKey: "id"
    #keyType: "int"
    +incrementing: true
    #with: []
    #withCount: []
    #perPage: 15
    +exists: false
    +wasRecentlyCreated: false
    #attributes: []
    #original: []
    #changes: []
    #casts: []
    #dates: []
    #dateFormat: null
    #appends: []
    #dispatchesEvents: []
    #observables: []
    #relations: []
    #touches: []
    +timestamps: true
    #visible: []
    #fillable: []
  }

那些。它找不到任何条目,尽管有条目:

桌子

有什么问题?怎么修?

php
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-02-22 22:39:34 +0000 UTC

如何在一种控制器方法中不验证字段

  • 0

框架:Laravel 5.7.27 (PHP 7.2.10 )

有几种方法可以通过显式指定请求类在服务器上进行验证:public function store(PostRequest $request)

该文件PostRequest.php指定了验证规则:

public function rules()
{
    return [
        'title' => 'required|min:10',
        'text' => 'required|min:10',
        'image' => 'required|file|image',
    ];
}

image在所有情况下,都需要根据规则进行图像验证required,但在一种方法中不需要,我该如何防止呢?

php
  • 2 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-02-15 20:36:26 +0000 UTC

从同一对象获取对象属性[重复]

  • 0
这个问题已经在这里得到了回答:
扫雷游戏场地设置 (1个回答)
3年前关闭。

我有一个 VueJS 应用程序。您需要从对象中获取同一对象的属性之一。

data: {
        users: [],
        api: {
            endpoint: 'http://afshuka/api',
            getUsers: this.endpoint + '/getUsers'
        }
    }

但是当被要求时,它this.api.getUsers会给出以下内容:undefined/getUsers

我如何endpoint进入同一个对象。

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-12-27 20:11:33 +0000 UTC

启动 Visual Studio Code 或 Atom 时 Ubuntu 崩溃

  • 4

当我启动 Visual Studio Code 或 Atom 时,系统立即崩溃,只是注销了用户,我该怎么办?

linux
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-11-11 03:35:01 +0000 UTC

解析相同布局但数据更改的页面

  • 0

有一个 HTML、CSS 和 JS 的小网站。我必须创建具有相同布局但有一些数据更改的多个页面。我想通过 PHP 文件制作整个网站,例如expert.php?id=1,但我记得GitHub Pages不支持 PHP。所以,我需要一个站点的构建系统,这样我就可以方便地将布局存储在一个文件中,其余的数据需要插入到这个布局中。

php
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-11-06 01:59:53 +0000 UTC

在 Ubuntu 上使用单声道

  • 1

C# 中有一个控制台应用程序,在 Windows 上一切正常,但需要将此应用程序放在运行 Ubuntu Server 18.04 x86_64 的服务器上。运行该命令后,mono RHBot.exe显示如下错误:

Unhandled Exception:
System.DllNotFoundException: SQLite.Interop.dll
  at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum)
  at System.Data.SQLite.SQLite3.StaticIsInitialized () [0x0001c] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteLog.Initialize (System.String className) [0x00026] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString, System.Boolean parseViaFramework) [0x00046] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString) [0x00000] in <226287aa71b9481b9dd405c36cfaba76>:0
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:.ctor (string)
  at VKBot.Program.Main (System.String[] args) [0x0006e] in <69f24e52cda4494abdf8dac4c5408e44>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: SQLite.Interop.dll
  at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum)
  at System.Data.SQLite.SQLite3.StaticIsInitialized () [0x0001c] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteLog.Initialize (System.String className) [0x00026] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString, System.Boolean parseViaFramework) [0x00046] in <226287aa71b9481b9dd405c36cfaba76>:0
  at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString) [0x00000] in <226287aa71b9481b9dd405c36cfaba76>:0
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:.ctor (string)
  at VKBot.Program.Main (System.String[] args) [0x0006e] in <69f24e52cda4494abdf8dac4c5408e44>:0

虽然它SQLite.Interop.dll在文件夹x86和x64. 该怎么办?

c#
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-11-04 06:15:38 +0000 UTC

在 Linux Ubuntu 上运行 C# 应用程序 [关闭]

  • 2
关闭。这个问题需要具体说明。目前不接受回复。

你想改进这个问题吗? 重新构建问题,使其只关注一个问题。

3年前关闭。

改进问题

我正在用 C# 编写一个控制台应用程序,我确实需要将它转移到 Linux Ubuntu 下的服务器上,但我不知道如何。听说过一个名为 Mono 的项目,但我不明白如何使用它。如果有与他合作的教程,我会很高兴。提前致谢。

c#
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-11-02 04:30:53 +0000 UTC

完全清理本地提交

  • 0

有这样一个问题:如何重置所有本地提交并从服务器重新下载?这些文件也必须删除。

git
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-11-01 17:22:43 +0000 UTC

无法将文本写入文件

  • 1

我无法将字符串写入文件,我不明白出了什么问题。堆栈跟踪:

   в System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   в System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   в System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   в System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   в System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   в System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   в VKBot.Program.Main(String[] args) в C:\Development\botdita\Program.cs:строка 648

此块中的代码:

            using (StreamReader sr = new StreamReader(reportFile, System.Text.Encoding.Default))
            {
                text = sr.ReadToEnd();
            }
            using (StreamWriter sw = new StreamWriter(reportFile, false, System.Text.Encoding.Default))
            {
                text += String.Format("REPORT из конференции ID{0} от @id{3}({1} {2}): {4}\n", chatID, from.FirstName, from.LastName, senderID, arg);
                sw.WriteLine(text);
            }

当我尝试使用File.AppendAllText()它时,它给出了同样的错误:

   в System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   в System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   в System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   в System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   в System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   в System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   в System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding)
   в VKBot.Program.Report(String arg) в C:\Development\botdita\Program.cs:строка 635
   в VKBot.Program.Command(String Message) в C:\Development\botdita\Program.cs:строка 519
   в VKBot.Program.Watcher_NewMessages(VkApi owner, ReadOnlyCollection`1 messages) в C:\Development\botdita\Program.cs:строка 835
   в VKBot.Program.<WatchAsync>d__54.MoveNext() в C:\Development\botdita\Program.cs:строка 935
c#
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-10-31 15:15:31 +0000 UTC

ON DUBLICATE 附近的语法错误

  • 0

我正在使用 SQLite。该请求INSERT INTO conversations (id,chiefs) VALUES (3,123) ON DUPLICATE KEY UPDATE chiefs=123;引发错误:Ошибка при выполнении SQL запроса к базе данных 'db': near "DUPLICATE": syntax error。怎么回事,谁能告诉我?

sql
  • 2 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-10-29 19:01:21 +0000 UTC

捕获控制台程序关闭

  • 4

有一个控制台应用程序(C#),我需要捕捉它的关闭事件。这可以是Ctrl+C单击十字,通常是程序将关闭的任何事件。如何才能做到这一点?

c#
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-02-04 15:24:25 +0000 UTC

高级评级输出

  • 3

有一个 MySQL 表(用户),其中数据是 id、name、points。我需要得到 3 行:1 人得分多,我和 1 人得分少。例子 请帮助如何做到这一点?

php
  • 2 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-12-31 19:58:41 +0000 UTC

浏览器仍然缓存文件数据

  • 3

我有一个无法缓存的 JSON 文件。我使用 JS 从 history.php 文件中请求它:

$.getJSON("./data/history/" + <?php echo $data['id']; ?> + ".json", function(data) {
                    var history_data = '';
                    $.each(data, function(key, value) {
                        history_data += '<tr>';
                        history_data += '<td>' + value.time + '</td>';
                        if (value.counts > 0) {
                            history_data += '<td class="hiscountsg">+' + value.counts + '</td>';
                        } else {
                            history_data += '<td class="hiscountsr">' + value.counts + '</td>';
                        }
                        history_data += '<td>' + value.owner + '</td>';
                        history_data += '</tr>';
                    });
                    $('#histab').append(history_data);
                });

一切正常显示,但是更新文件89.json时,请求这个文件时,显示旧值。在发送此请求的文件中,有一个用于设置 http 标头以禁用缓存的功能:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0,pre-check=0", false);
header("Cache-Control: max-age=0", false);
header("Pragma: no-cache");

请帮忙,我不知道该怎么办。

PS 在禁用缓存的 Firefox 开发者版浏览器中,一切正常

php
  • 1 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-12-27 00:43:50 +0000 UTC

在数组中查找对象

  • 0

有这个 JSON 文件:

{
  "terminals": [
    {
      "token": "hile_abcd1234",
      "name": "Hile Group Authorized Agent",
      "scopes": [
        "r"
      ]
    },
    {
      "token": "hile_absd1234",
      "name": "Hile Group Authorized Agent 2",
      "scopes": [
        "w"
      ]
    }
  ]
}

如何找到tokenhile_absd1234并返回它所在的数组?

php
  • 3 个回答
  • 10 Views
Martin Hope
Ivan Petrov
Asked: 2020-12-19 23:14:52 +0000 UTC

将字符串拆分为由 TAB 分隔的数组

  • 3

他们通过制表将数字放入表格中:

4   5   4   4   3   2   3

我需要将它们拆分为一个数组,为此我使用.split(" ");但是在选项卡内时,它不会正确地换行。

如果分隔符是制表符,如何将字符串拆分为数组?

javascript
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5