How to specify id when uses include in layout xml file

前端 未结 11 2613
挽巷
挽巷 2020-12-02 08:55

In my layout xml file, I have included other layout xml file (each with a different android id).



        
11条回答
  •  孤城傲影
    2020-12-02 09:39

    I found out, that if you are using tag in your include layout, then the ID of include transfers to the merge tag which is not real view.

    So either remove merge, or replace it with some layout.

    Tor Norbye wrote:

    The tag is not a real view, so findByView will not find it. The @id attribute (and any other attributes you've set on the include tag) gets applied on the root tag of the included layout instead. So your activity.getView(R.id.included1) should in fact be the itself.

提交回复
热议问题