Include same layout multiple times

前端 未结 4 1140
抹茶落季
抹茶落季 2021-02-13 21:56

I have a common layout (common.xml) which I want to include many times in another layout (layout_a.xml). But it only shows me just one time. Why?

common.xml

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 22:23

    The ids when defined in XML must be unique. You are including two layouts that have views that contain the same id.

    Here is how you would go about fixing it.

    p.s. Unless there is more code that you are not including in your first layout file, that merge tag is useless.

提交回复
热议问题