How can I programmatically include layout in Android?

后端 未结 3 2017
臣服心动
臣服心动 2020-12-02 06:56

I\'m looking for a way to include a layout programmatically instead of using the XML tag include like in my example:

  

        
3条回答
  •  鱼传尺愫
    2020-12-02 07:27

    ViewStub stub = (ViewStub) findViewById(R.id.text_post);
            stub.setLayoutResource(R.layout.profile_header);
            View inflated = stub.inflate();
    

提交回复
热议问题