小编Ada*_*_SL的帖子

旋转屏幕后,Recyclerview不会调整大小

我有一个Recyclerview填充了用户插入的项目.我正在实现旋转的功能,因为当我转动设备时,recyclerview显示为空.

调试应用程序,我已经检查旋转之前和之前的完整性,并且ArrayList具有相同的大小.我认为问题是setNestedScrollingEnabled(false)Recyclerview,我设置这个是因为我不想在rv中显示滚动.

问题是:我处于纵向模式,我添加了3个项目,它在recyclerview中显示我很完美.检查图像:

肖像

当我将屏幕旋转到横向时,recyclerview的arraylist有3个项目,但高度不会改变,所以它只有一个项目.

在此输入图像描述

那么,我如何解决这个问题?

Recyclerview:

itemsRv = (RecyclerView) findViewById(R.id.itemsRv);
itemsRv.setNestedScrollingEnabled(false);
itemAutoCompleteAdapter = new ItemAutoCompleteAdapter(this);
if(items ==null){
   items = new ArrayList<>();
}
itemsAdapter = new ItemsRowAdapter(this, items, new ItemsRowAdapter.itemsRowListener() {
  @Override
  public void editarItemOnClick(View v, int position) {
  editar_item(items.get(position), position);
  }

  @Override
  public void eliminarItemOnClick(View v, final int position) {

  }
});
itemsRv.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
itemsRv.setLayoutManager(mLayoutManager);
itemsRv.setAdapter(itemsAdapter);
Run Code Online (Sandbox Code Playgroud)

布局:

  <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="8dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="8dp">

                <android.support.v7.widget.AppCompatTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:layout_marginBottom="4dp"
                    android:text="Items"
                    android:textSize="16sp" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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

如何创建通配符以拒绝来自 AWS WAF 中所有 ip 的所有请求

我在 WAF 后面的 AWS ECS 实例中获得了一个微服务,我想创建以下规则:

  1. 允许特定IP(完成)
  2. 允许来自 VPN 内部的所有连接(完成)
  3. 拒绝所有其他请求。

前两个 IP 集已创建,但我无法使最后一个 IP 集工作。我尝试使用 和其他组合创建 IP 集,0.0.0.0/0但没有成功。

这是我的代码,我删除了 ipset 1 和 2(正在工作),这是 ipset 3:

resource "aws_wafv2_ip_set" "ipset" {
  name = "${var.app_name}-${var.environment_name}-whitelist-ips"

  scope              = "REGIONAL"
  ip_address_version = "IPV4"

  addresses = ["0.0.0.0/0"]
}

module "alb_wafv2" {
  source = "trussworks/wafv2/aws"
  version = "~> 2.0"

  name = "${var.app_name}-${var.environment_name}"
  scope = "REGIONAL"
  alb_arn = aws_lb.app_lb.arn
  associate_alb = true

  ip_sets_rule = [
    {
      name       = "${var.app_name}-${var.environment_name}-ip-blacklist"
      action     = "deny"
      priority   = 1 …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform web-application-firewall terraform-provider-aws

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