小编Igo*_*yuk的帖子

在 SearchView [库存应用程序] 中搜索项目时无法通过滑动删除

实际上我正在尝试制作一个库存应用程序。

因此,在扫描一些条形码后,我将它们添加到 an 中ArrayList,然后在 a 中recyclerView,我的recyclerView有一个过滤方法和 a ,searchView因此用户应该能够搜索投掷条形码,并且必须能够在滑动时删除搜索到的项目。

当我打开我的recyclerView项目时dialogAlert,如果我删除项目,一切正常,但是当我搜索一个项目并将其删除,然后我关闭该项目时,searchView该项目仍然保留在recyclerView.

我将在此处提供我的适配器代码,以及我在活动中构建和删除项目的代码。

这是活动中的代码:

@SuppressLint("SetTextI18n")
@TargetApi(Build.VERSION_CODES.KITKAT)
public void alertDeleteSingleItem(final int position){
    final AlertDialog.Builder mBuilder = new AlertDialog.Builder(InventarioActivity.this);

    @SuppressLint("InflateParams") View mView = getLayoutInflater().inflate(R.layout.alert_confirm_delete, null);

    final Button yes = mView.findViewById(R.id.btnSI);
    final Button no = mView.findViewById(R.id.btnNO);
    final TextView text = mView.findViewById(R.id.textView);

    text.setText("ELIMINARE " + itemAdapter.getList().get(position).getCodiceArticolo() + " ?");

    mBuilder.setView(mView);
    final AlertDialog dialog = mBuilder.create();
    Objects.requireNonNull(dialog.getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    dialog.show();


    yes.setOnClickListener(new View.OnClickListener() {
        @Override …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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

动态生成时引导选项卡不起作用

我在我的网站中使用以下引导程序选项卡,从 ajax 请求动态生成。

当我尝试这些选项卡的静态版本时,所有选项都运行良好,但是现在当我按下选项卡时动态生成所有选项卡和窗格时,它只是没有将显示属性设置为它的窗格..

随着内容是动态添加的,点击是由 .on('click', 'a'..)

这是代码片段...

我只是找不到我生成的错误,因为动态代码等于静态代码..

$('#tab').on('click', 'a', function(e) {
  e.preventDefault()
  $(this).tab('show');
})
Run Code Online (Sandbox Code Playgroud)
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
<nav class="nav-scroller py-1 pb-1 mb-2">
  <div class="nav nav-tabs d-flex justify-content-between" id="tab" role="tablist">
    <a class="nav-item p-2 text-muted menu active" id="4-men" href="#4-tab" data-toggle="tab" role="tab" aria-controls="4-tab" aria-selected="true" data-id="4">RINFESCHI</a><a class="nav-item p-2 text-muted menu" id="12-men" href="#12-tab" data-toggle="tab"
      role="tab" aria-controls="12-tab" aria-selected="false" data-id="12">PRALINERIA</a><a class="nav-item p-2 text-muted menu" id="13-men" href="#13-tab" data-toggle="tab" role="tab" aria-controls="13-tab" aria-selected="false" data-id="13">CONFEZIONI</a>
    <a
      class="nav-item p-2 text-muted menu" id="14-men" href="#14-tab" …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery bootstrap-4

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

IIS: redirect to index when page not found

In my IIS Website i have three applications hosted on it, the main website is an Angular App, when i have API application where all APIs are hosted and another application that is a pure javascript project hosted under application alias /vmenu/.

Each request that comes to example.com/v/ should be redirected to /vmenu/ and i've yet added that rewrite rule to my web.config

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rewrite VMenu">
                    <match url="^v/(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" />
                    <action type="Rewrite" url="api/{R:0}" appendQueryString="false" />
                </rule>
            </rules> …
Run Code Online (Sandbox Code Playgroud)

iis angular

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

如何在 Bootstrap 5 中以编程方式打开 offcanvas?

我的网页中有一个底部offcanvas,我会通过尝试设置所需的属性或使用文档中的代码,通过单击卡片来打开它,但它不起作用,因为offcanvas仅显示背景并立即将其关闭。

这是我尝试过的:

const products = document.getElementsByClassName("card product");

var productClick = function (event) {
    event.preventDefault()
    var myOffcanvas = document.getElementById('offcanvasBottom')
    var bsOffcanvas = new bootstrap.Offcanvas(myOffcanvas)
    bsOffcanvas.show();
};

Array.from(products).forEach(function (element) {
  element.addEventListener("click", productClick);
});
Run Code Online (Sandbox Code Playgroud)
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>


<div class="card product" style="width: 18rem">
  <div class="card-body text-center">
    <h2 class="card-title fw-bolder">TEST</h2>
    <p class="card-text fw-bolder">TEST</p>
  </div>
</div>

      <div
        class="offcanvas offcanvas-bottom"
        tabindex="-1"
        id="offcanvasBottom"
      >
        <div class="offcanvas-header">
          <button
            type="button"
            class="btn-close text-reset"
            data-bs-dismiss="offcanvas"
            aria-label="Close"
          ></button>
        </div>
        <div class="offcanvas-body">
         BODY
        </div>
      </div>
Run Code Online (Sandbox Code Playgroud)

javascript bootstrap-5

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

尝试投射“attachBadgeDrawable”时的 Kotlin 问题:此声明是可选的

BadgeDrawable我会在我的 Android 应用程序中使用a Button,问题是当我尝试设置按钮布局时,badgeDrawableattachBadgeDrawable收到一个错误,其中显示:

his declaration is opt-in and its usage should be marked with  '@com.google.android.material.badge.ExperimentalBadgeUtils' or '@OptIn(markerClass = com.google.android.material.badge.ExperimentalBadgeUtils.class)'
Run Code Online (Sandbox Code Playgroud)

我使用那段代码的代码如下:

            btnInvia.viewTreeObserver.addOnGlobalLayoutListener(
                object : OnGlobalLayoutListener {
                    override fun onGlobalLayout() {
                        val badgeDrawable = BadgeDrawable.create(requireContext())
                        badgeDrawable.number = corpo
                        badgeDrawable.verticalOffset = 20
                        badgeDrawable.horizontalOffset = 15
                        BadgeUtils.attachBadgeDrawable(badgeDrawable, btnInvia, layoutInvia)
                        btnInvia.viewTreeObserver.removeOnGlobalLayoutListener(this)
                    }

                }
            )
Run Code Online (Sandbox Code Playgroud)

如果有用的话最小 SDK 是 24。

android kotlin android-annotations material-components-android androidx

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

如何检测前置摄像头是否在android中可用?

实际上,我的应用程序存在一些问题,

就像我有一个按钮可以打开前置摄像头并扫描服务员徽章,但是当我尝试检查设备是否有摄像头,如果没有,我只是隐藏了那个按钮,问题就来了。

但是我有一个使用前置摄像头作为 QR 扫描仪的设备,所以它并不是真正可以使用的摄像头,因此当我尝试单击该按钮时应用程序崩溃。

所以问题是我如何处理和检查不仅相机存在,而且即使它可以工作?

crash camera android

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

Cookie.ExpireTimeSpan 被忽略并在 CookieAuthentication 中设置为 Session

我有一个问题,而试图设置过期我一个cookie的时候CookieAuthentication,似乎ExpireTimeSpan只是忽略,当我得到在浏览器cookie的它的到期时间设置为Session..

我正在使用带有 .NET Core 3.1 的 c# 8.0,这是我的ConfigureService代码:

    public void ConfigureServices(IServiceCollection services)
    {

        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
        .AddCookie(options => {
            options.Cookie.Name = "authToken";
            options.ExpireTimeSpan = TimeSpan.FromMinutes(120);
            options.Events = new CookieAuthenticationEvents()
            {
                OnRedirectToLogin = (context) =>
                {
                    context.HttpContext.Response.Redirect("https://example.com/test/expired.html");
                    return Task.CompletedTask;
                }
            };
        });
        services.AddControllers();
    }
Run Code Online (Sandbox Code Playgroud)

但这就是我得到它的方式

在此处输入图片说明

c# asp.net-web-api cookie-authentication

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

在改造 Android 中设置超时?

实际上,我正在通过 Retrofit 向我的服务器发送一个 txt 文件,并且一切正常,如果没有连接,我什至可以捕获 onFailure 方法。

但是当我离开 Wi-Fi 区域然后我发送文件并重新进入 Wi-Fi 区域时问题就出现了,该文件将被发送但 onFailure 方法被激活。

那么我怎样才能像 onResponse 方法的超时或类似的东西发送呢?

这是我的 Activity 中的 sendPost 方法:

 @SuppressLint("DefaultLocale")
    public void sendPost() {
        @SuppressLint({"SdCardPath", "DefaultLocale"}) final File file = new File("/data/data/com.example.igardini.visualposmobile/files/"+String.format("%03d", Integer.valueOf(nTerminalino))+"_"+nTavoli.getText().toString()+".txt");

        MultipartBody.Builder builder = new MultipartBody.Builder();
        builder.setType(MultipartBody.FORM);

        RequestBody fbody = RequestBody.create(MediaType.parse("text/*"), file); builder.addFormDataPart(String.format("%03d", Integer.valueOf(nTerminalino))+"_"+nTavoli.getText().toString(), file.getName(),fbody);

        MultipartBody requestBody = builder.build();

        APIService apiService = ApiUtils.getAPIService(ipCASSA);

        Call<Void> call = apiService.savePost(requestBody);

        call.enqueue(new Callback<Void>() {
            @Override
            public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
                if (response.isSuccessful()) {
                    Log.i("RESPONSE: ", …
Run Code Online (Sandbox Code Playgroud)

android timeout http retrofit

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

Material Chip 输入小部件只能与 Theme.AppCompat 一起使用

在我使用 AutoCompleteEditText 和 ChipGroup 创建布局后,我试图在我的 Android 应用程序中创建一个 ChipInput,我将动态创建的 Chip 添加到其中,但在堆栈跟踪中出现以下错误:

E/ThemeUtils:视图类 com.google.android.material.chip.Chip 是一个 AppCompat 小部件,只能与 Theme.AppCompat 主题(或后代)一起使用。

此组件上的样式要求您的应用程序主题为 Theme.MaterialComponents(或其后代)。

问题是我的主题尚未设置为材质,但我仍然收到该错误,我什至尝试以编程方式将主题设置为芯片,但仍然出现该错误。

这是我以编程方式添加芯片的代码

private fun addChipToGroup(person: String, chipGroup: ChipGroup) {
    val chip = Chip(applicationContext)
    chip.text = person
    chip.isCloseIconVisible = true

    // necessary to get single selection working
    chip.isClickable = true
    chip.isCheckable = false
    chipGroup.addView(chip as View)
    chip.setOnCloseIconClickListener { chipGroup.removeView(chip as View) }
}
Run Code Online (Sandbox Code Playgroud)

应用程序在该方法的第一行崩溃

android android-theme kotlin android-chips material-components-android

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

更改 recyclerView 项目背景 onClick?

当我按下我的按钮时,我会这样做recyclerView,这会改变它的背景颜色,这样按下的按钮就会可见,但我不太喜欢android,所以我不知道如何做到这一点。

我尝试过在网上找到的一些指南,但其中大多数对我不起作用,就像在本指南中按钮没有颜色而只是白色。我会做一些类似 我的活动屏幕的事情

这是我的recyclerView适配器代码:

public class RecyclerViewMenu extends RecyclerView.Adapter<RecyclerViewMenu.MenuViewHolder> {

private ArrayList<MenuConstructor> menuConstructors;
private OnItemClickListener onItemClickListener;

public interface  OnItemClickListener {
    void onItemClick(int position);
}

public void setOnItemClickListener(OnItemClickListener listener){
    onItemClickListener = listener;
}

@NonNull
@Override
public MenuViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.menucard,parent,false);
    return new MenuViewHolder(v, onItemClickListener);

}


RecyclerViewMenu(ArrayList<MenuConstructor> menuList){
    menuConstructors = menuList;
}

@Override
public void onBindViewHolder(@NonNull final MenuViewHolder holder, final int position) {


    MenuConstructor currentItem = menuConstructors.get(position);

    holder.textView.setText(currentItem.getDesk());
    holder.itemView.setBackgroundColor(Color.parseColor(currentItem.getSfondoColor())); …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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