Android - Dynamically Add Views into View

后端 未结 5 2077
情书的邮戳
情书的邮戳 2020-11-22 03:58

I have a layout for a view -



        
5条回答
  •  执念已碎
    2020-11-22 04:40

    See the LayoutInflater class.

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ViewGroup parent = (ViewGroup)findViewById(R.id.where_you_want_to_insert);
    inflater.inflate(R.layout.the_child_view, parent);
    

提交回复
热议问题