RelativeLayout and ViewStub inflation

后端 未结 4 1523
[愿得一人]
[愿得一人] 2021-02-07 22:27

I have the following layout.



        
4条回答
  •  礼貌的吻别
    2021-02-07 23:06

    It's an old question, but I've got a useful addition

    1) Yes, like others have posted - use same id and inflatedId:

    
    

    2) When you need to inflate view or refresh its content it's convenient to act like this:

        View v = parentView.findViewById(R.id.view_stub_id);
        if (v instanceof ViewStub)
            v = ((ViewStub) v).inflate();
    
        // here v is always the inflated view
        // ...
    

提交回复
热议问题