android – 在appcompat_v7中复制id @ id / image abc_activity_chooser_view.xml:58

前端之家收集整理的这篇文章主要介绍了android – 在appcompat_v7中复制id @ id / image abc_activity_chooser_view.xml:58前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在创建apk时出现以下错误

“重复id @ id / image,已在此布局中定义…. abc_activity_chooser_view.xml:布局中的58(appcompat_v7)”

所以我清理它,仍然是一样的.此文件中确实存在重复的id @ id / image:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <view xmlns:android="http://schemas.android.com/apk/res/android"
  3. class="android.support.v7.internal.widget.ActivityChooserView$InnerLayout"
  4. android:id="@+id/activity_chooser_view_content"
  5. android:layout_width="wrap_content"
  6. android:layout_height="match_parent"
  7. android:layout_gravity="center"
  8. style="?attr/activityChooserViewStyle">
  9.  
  10. <FrameLayout
  11. android:id="@+id/expand_activities_button"
  12. android:layout_width="wrap_content"
  13. android:layout_height="match_parent"
  14. android:layout_gravity="center"
  15. android:focusable="true"
  16. android:addStatesFromChildren="true"
  17. android:background="?attr/actionBarItemBackground">
  18.  
  19. <ImageView android:id="@+id/image"
  20. android:layout_width="32dip"
  21. android:layout_height="32dip"
  22. android:layout_gravity="center"
  23. android:layout_marginTop="2dip"
  24. android:layout_marginBottom="2dip"
  25. android:layout_marginLeft="12dip"
  26. android:layout_marginRight="12dip"
  27. android:scaleType="fitCenter"
  28. android:adjustViewBounds="true" />
  29.  
  30. </FrameLayout>
  31.  
  32. <FrameLayout
  33. android:id="@+id/default_activity_button"
  34. android:layout_width="wrap_content"
  35. android:layout_height="match_parent"
  36. android:layout_gravity="center"
  37. android:focusable="true"
  38. android:addStatesFromChildren="true"
  39. android:background="?attr/actionBarItemBackground">
  40.  
  41. <ImageView android:id="@+id/image"
  42. android:layout_width="32dip"
  43. android:layout_height="32dip"
  44. android:layout_gravity="center"
  45. android:layout_marginTop="2dip"
  46. android:layout_marginBottom="2dip"
  47. android:layout_marginLeft="12dip"
  48. android:layout_marginRight="12dip"
  49. android:scaleType="fitCenter"
  50. android:adjustViewBounds="true" />
  51.  
  52. </FrameLayout>
  53.  
  54. </view>

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

解决方法

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

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

猜你在找的Android相关文章