How to get a reference to an XML file from FrameLayout

后端 未结 1 1864
我在风中等你
我在风中等你 2021-01-02 08:34

I need to get reference to separate XML file which is FrameLayout but I can\'t figure out how to do it, this code doesn\'t work:

FrameLayout desktopFrameLayou         


        
1条回答
  •  一向
    一向 (楼主)
    2021-01-02 09:12

    For that you have to use inflate view.

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View view = inflater.inflate(R.layout.mylayout, null);
    
    FrameLayout item = (FrameLayout ) view.findViewById(R.id.desktopsFramelayout);
    

    0 讨论(0)
提交回复
热议问题