appcompat_v7 abc_activity_chooser_view.xml:58中的ID @ + id/image重复 [英] Duplicate id @+id/image in appcompat_v7 abc_activity_chooser_view.xml:58

查看:60
本文介绍了appcompat_v7 abc_activity_chooser_view.xml:58中的ID @ + id/image重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建apk时,出现以下错误:

While creating the apk I got the following error :

重复的ID @ + id/图像,已在此布局的前面定义.... abc_activity_chooser_view.xml:58在布局(appcompat_v7)中"

"Duplicate id @+id/image, already defined earlier in this layout .... abc_activity_chooser_view.xml:58 in layout (appcompat_v7)"

所以我清理了它,还是一样.该文件中确实存在重复的ID @ + id/image:

So I cleaned it, still the same. There is indeed duplicate id @+id/image in this file :

<?xml version="1.0" encoding="utf-8"?>
<view xmlns:android="http://schemas.android.com/apk/res/android"
class="android.support.v7.internal.widget.ActivityChooserView$InnerLayout"
android:id="@+id/activity_chooser_view_content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
style="?attr/activityChooserViewStyle">

<FrameLayout
    android:id="@+id/expand_activities_button"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:focusable="true"
    android:addStatesFromChildren="true"
    android:background="?attr/actionBarItemBackground">

    <ImageView android:id="@+id/image"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:layout_gravity="center"
        android:layout_marginTop="2dip"
        android:layout_marginBottom="2dip"
        android:layout_marginLeft="12dip"
        android:layout_marginRight="12dip"
        android:scaleType="fitCenter"
        android:adjustViewBounds="true" />

</FrameLayout>

<FrameLayout
    android:id="@+id/default_activity_button"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:focusable="true"
    android:addStatesFromChildren="true"
    android:background="?attr/actionBarItemBackground">

    <ImageView android:id="@+id/image"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:layout_gravity="center"
        android:layout_marginTop="2dip"
        android:layout_marginBottom="2dip"
        android:layout_marginLeft="12dip"
        android:layout_marginRight="12dip"
        android:scaleType="fitCenter"
        android:adjustViewBounds="true" />

  </FrameLayout>

</view>

有关如何处理此问题的任何想法?显然,我不能只是将其重命名. 我可以跳过Lint中的检查,但是错误仍然存​​在,我认为这不是最好的解决方案.还有更可靠的解决方案吗?

Any ideas of how to deal with this ? Obviously I can't just rename it. I can skip checking it in Lint, but the error still persists and I don't think this is the best solution. Any more reliable solutions ?

推荐答案

您会收到重复的ID错误,因为android.support.v7.internal.widget.ActivityChooserView$InnerLayout中存在一个具有相同名称的视图.简单的答案是为您的ImageView使用一个新名称,并在引用它的任何地方在代码中更新该名称.

You are getting a duplicate ID error because there is a view with the same name in android.support.v7.internal.widget.ActivityChooserView$InnerLayout. The simple answer is to use a new name for your ImageView and update the name in your code anywhere you reference it.

请问为什么您直接在布局中使用内部框架小部件?内部布局不建议直接使用,并且随时可能更改,这可能会在将来破坏您的代码.更好的解决方案是创建自己的布局或使用具有类似功能的公共框架小部件.使用内部窗口小部件需要您自担风险.

May I ask why you are using an internal framework widget directly in your layout? Internal layouts are not meant to be used directly and are subject to change at any time, which may break your code in the future. The better solution is to create your own layout or use a public framework widget with similar functionality. Use of an internal widget is done at your own risk.

这篇关于appcompat_v7 abc_activity_chooser_view.xml:58中的ID @ + id/image重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆