小编Leo*_*uza的帖子

更新片段不起作用

我正在学习Android,在尝试开发应用程序时遇到以下情况:

我有一个活动有两个Fragments:ReminderListFragmentFilterListFragment.第一个片段有一个提醒列表,第二个片段有一个过滤器列表,其中包含每个过滤器中注册的项目名称和数量.但是,当我排除某些提醒时,FilterListFragment值不会更新.当我删除其中一个过滤器时会发生同样的事情(在这种情况下,它会删除所选过滤器的所有记录),它不会更新"提醒"列表.

在此输入图像描述

FilterListFragment 码:

    @Override
        public boolean onContextItemSelected(MenuItem item) {
            if (item.getGroupId() == R.id.context_menu_category) {
                // Used to verify it it is the right context_menu //Gets the item
                // position and gets the category in that position:
                AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
                Category category = ((CategoryFilter) lvFilters.getAdapter().getItem(info.position)).getCategory();

                // Switch between the options in the context menu(Edit and Delete)
                switch (item.getItemId()) {
                case R.id.edit:
                    // Passes the current reminder to be edited via Intent and …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-fragments

15
推荐指数
2
解决办法
319
查看次数

.NET 7:已成功与服务器建立连接,但在登录过程中出现错误

将项目迁移到后,.NET 7我必须TrustServerCertificate=true;在连接字符串中添加设置,否则会引发以下错误:SqlException: A connection was successfully established with the server, but then an error occurred during the login process

在 .NET 5 或 6 中,这是不必要的。谁能告诉我为什么需要在连接字符串中添加此设置?

本地连接字符串:

Server=localhost;Database=Xpz;Integrated Security=SSPI;TrustServerCertificate=true;
Run Code Online (Sandbox Code Playgroud)

.net entity-framework .net-7.0

11
推荐指数
3
解决办法
2万
查看次数

算法的复杂性和问题的复杂性。有什么区别?

我想知道一个算法复杂度和一个问题复杂度之间的区别,也就是这两个东西的不同点

complexity-theory time-complexity computation-theory space-complexity

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

如何在Asp.Net Core中的JsonResult中返回错误状态?

我试图在将 Asp.Net MVC 5 应用程序迁移到 Core 版本后返回错误状态。

在我的旧应用程序中,我使用了一个JsonHttpStatusResult继承自JsonResult并返回捕获错误(如果有)的类()。然而,当尝试将其添加到新项目时,不幸的是它不再具有某些功能。

我想对 Asp.Net Core 版本使用相同的概念,因为如果JsonResult. 以下是它在 MVC 5 中如何工作的示例:

班级

public class JsonHttpStatusResult : JsonResult
{
    private readonly HttpStatusCode _httpStatus;

    public JsonHttpStatusResult(object data, HttpStatusCode httpStatus)
    {
        Data = data;
        _httpStatus = httpStatus;
    }

    public override void ExecuteResult(ControllerContext context)
    {
        context.RequestContext.HttpContext.Response.StatusCode = (int)_httpStatus;
        base.ExecuteResult(context);
    }
}
Run Code Online (Sandbox Code Playgroud)

示例JSONRESULT

public JsonResult Example()
{
    try
    {
        //Some code
        return Json(/*something*/);
    }
    catch (Exception ex)
    {
        return new …
Run Code Online (Sandbox Code Playgroud)

asp.net-ajax asp.net-core

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

查询参数 swagger 中的字符串数组

我正在开发一个项目,其中有一个端点接收参数中的字符串列表,如下面的代码所示:

public class PaymentFilter
{
    public List<string> Status  {get; set; }
}

[HttpGet]
public IActionResult Get([FromQuery] PaymentFilter filter)
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

但是,在swagger界面中,状态列表没有反映出来,如图所示:

在此输入图像描述

如何启用状态列表条目?

swagger-ui asp.net-core

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