nutiteq:按钮分别。可点击视图在自定义视图标签中不起作用

2024-01-21

我能够在 Android nutiteq 中制作完全定制的 ViewLabel,定义布局设计和尺寸。但是,可点击视图未按预期工作。首先,我尝试通过将根布局定义为可单击来使整个标签可单击,但这不起作用。添加按钮也不起作用。如何解决这个问题呢?

MapPos markerLoc = rasterLayer.getProjection().fromWgs84(lng, lat);
Marker marker;

CustomPOILayout layout = new CustomPOILayout(this);
layout.setTitle((poi.title.trim().length() == 0)? "kein Titel" : poi.title);
layout.setDescription((poi.desc.trim().length() == 0)? "keine Beschreibung" : poi.desc);
layout.setDateAndAuthor(COSAHelper.convertTimestamp(poi.resCreated) + "\nvon: " + poi.author);
layout.setImages(poi.byteStrings);

layout.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                        MeasureSpec.makeMeasureSpec(0,  MeasureSpec.UNSPECIFIED)); 
layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight());

Label label = new ViewLabel("", layout, 
                            new Handler(), 
                            LabelStyle.builder()
                                .setAlpha(1.0f)
                                .setBorderRadius(0)
                                .setBorderColor(Color.GRAY)
                                .setBorderWidth(5)
                                .build()
                            );


marker = new Marker(markerLoc, label, markerStyle3, markerLayer);
markerLayer.add(marker);

XML 布局

<TextView 
    android:id="@+id/label_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:textStyle="bold"
    />

<View 
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:background="@color/abc_search_url_text_normal"
    />

<TextView 
    android:id="@+id/label_date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="11sp"
    />

<TextView 
    android:id="@+id/label_description"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="14sp"
    />

<View 
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:background="@color/abc_search_url_text_normal"
    />

<LinearLayout 
    android:id="@+id/label_container1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    >
    <ImageView 
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_margin="5dip"
        android:minHeight="25dip"
        />

    <ImageView 
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_margin="5dip"
        android:minHeight="25dip"
        />
</LinearLayout>

<LinearLayout 
    android:id="@+id/label_container2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    >
    <ImageView 
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_margin="5dip"
        android:minHeight="25dip"
        />

    <ImageView 
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_margin="5dip"
        android:minHeight="25dip"
        />
</LinearLayout>

<TextView 
    android:id="@+id/label_text_images"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    />

<View 
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:background="@color/abc_search_url_text_normal"
    />

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="zeige Ressource"
    android:gravity="center"
    android:onClick="onClickTest"
    android:layout_gravity="center"
    android:textSize="14sp"/>

如果我理解正确的话,您希望所有点击都转发到标签内的视图吗?视图标签有这样的方法:设置触摸处理模式。只需致电viewLabel.setTouchHandlingMode(true).

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

nutiteq:按钮分别。可点击视图在自定义视图标签中不起作用 的相关文章

  • 使用 xamarin 和 c# 更改 android 上的cultureinfo

    我调用自定义方法来动态地将当前文化信息切换为法语 fr 像这样 但在调用该方法后 我的 Android 应用程序仍然使用默认区域性 en 但在调试模式下 区域性似乎没问题 我的文件夹没问题 我两者都有 并且字符串值已配置 文件夹 resou
  • 如果我无限期地在后台运行 Android 线程会发生什么

    Android 文档表明 Oreo 对后台执行有新的限制 https developer android com about versions oreo background https developer android com abou
  • OpenGL ES 2.0 中的透明对象

    所以我一直在 Android 上使用 OpenGL ES 2 0 但现在遇到了一个我无法解决的问题 提前道歉 看来我还不能发布两个以上的链接 所以我把我的三张图片放在 Photobucket 相册中 我正在尝试创建一个由透明区域 彩色玻璃
  • listview getChildAt() 返回 null

    我一直在做一个android项目并陷入了一个问题 我用谷歌搜索但没有找到答案 在我的项目中 有一个名为viewsurahfragment它包含一个 id 为的列表视图lv showquran 我想突出显示指定索引处的列表视图的视图 我正在使
  • 浮动操作按钮动画

    当 fab 出现时 它使用动画中的比例进行动画处理 当它隐藏时 它使用向外扩展动画 因此 它是一个缩小和缩小的动画 这个动画要怎么制作呢 从 Zielony 的回答来看 我完全按照我想要的方式制作了它 下面是正确应用效果的代码 scale
  • 更新房间迁移的行

    是否可以编写迁移来更新某个表的所有先前数据 我正在为我的房间数据开发加密 如果我可以在迁移后加密所有行 那就太好了 那么 在定义迁移时 您可以访问支持SQLite数据库 https developer android com referen
  • 更新语言时操作栏未更新

    我目前正在构建一个应用程序 允许人们在应用程序中更新语言 但是 当更改区域设置时 所有字符串都会更新 但操作栏中的字符串不会更新 对应于清单中的活动名称 仅当应用程序从头开始重新启动时才会考虑语言更改 在不强制应用程序重新启动的情况下更新所
  • 清除未接来电并清除 Android 栏中的通知

    使用此代码 我设法将所有未接来电标记为已读 ContentValues values new ContentValues values put Calls NEW 0 if android os Build VERSION SDK INT
  • FirebaseAuth - 让用户使用任何提供商更改密码 - Android

    我有一个社交媒体应用程序 我正在使用FirebaseUI让用户使用电子邮件 Google 或 Facebook 登录 注册应用程序 如果使用 电子邮件 作为密码 我怎样才能让用户稍后更改他 她的密码 提供商 如果使用 Facebook 或
  • 来自 InputStream 的 Android 通用图像加载器 URI

    我想问一下UIL URI是从InputStream输入的 因为我的图像源来自 ZIP 然后我必须提取它才能显示该图像 因为图像太大 我必须使用UIL库 任何人都知道如何从InputStream插入UIL 我认为你可以这样做类似于从数据库加载
  • 使用 android-async-http (loopj) 发布 JSON/XML

    我在用android async http http loopj com android async http 并且真的很喜欢它 我在发布数据时遇到了问题 我必须按照以下格式将数据发布到 API
  • android.os.FileUriExposedException 在 Oreo 中引起(仅!)[重复]

    这个问题在这里已经有答案了 从 Google Play Console 中 我可以看到此异常仅发生在 Android 8 0 的设备上 android os FileUriExposedException at android os Str
  • LibGDX 闪烁

    我已经使用 LibGDX UI 设置来启动一个项目 我在实现 ApplicationListener 中唯一拥有的是 public void create setScreen new LoadingScreen this 这应该会触发 Lo
  • 是否可以自定义首选项标题布局?

    我发现了类似的问题 但找不到最新的具体答案 我在用着
  • PhoneGap文件传输错误1、哪里写FileTransfers?

    相关 https stackoverflow com questions 21044197 download file and store them locally in sdcard using phonegapbuild https s
  • 如何使用游戏循环每五秒在屏幕上出现和消失一个对象

    我正在尝试学习 Android 游戏开发 首先 我尝试每五秒使用游戏循环在屏幕上出现和消失一个对象 但我没有成功 我读过不同的教程和论坛 我按照教程中的方式应用了所有内容 但对象仍然在连续绘制 它并没有消失 我没有得到我所缺少的东西 请指导
  • Android 位图到 WebRtc I420 帧损坏

    尝试通过 WebRtc 流式传输位图 我的 Capturer 类大约如下所示 public class BitmapCapturer implements VideoCapturer VideoSink private Capturer c
  • Android 开发:seekbar 倒计时!

    是否有可能 如果是 如何 如何在用户不执行任何操作的情况下从进度 100 变为 1 就像每0 05秒seekbar setProgress 1 因此 如果用户不执行任何操作 搜索栏就会下降 直到达到 1 请回答如何做到这一点 谢谢 clas
  • 获取定制旋转器项目

    我实现了自定义微调器 public class MyAdapter extends ArrayAdapter
  • Android 中的自定义相机应用程序问题 - 旋转 270、拉伸捕获视图且未获取所有功能

    我从代码中得到了帮助https github com josnidhin Android Camera Example https github com josnidhin Android Camera Example 但面临一些问题 例如

随机推荐