android dynamically add element from layout xml

后端 未结 2 1057
闹比i
闹比i 2021-01-04 14:23

How can I take the element myButton from this layout xml




        
2条回答
  •  生来不讨喜
    2021-01-04 15:08

    View view = LayoutInflater.from(context).inflate(R.layout.my_layout);
    Button button = (Button) view.findViewById(R.id.myButton);
    ....
    aGroupView.addView(button);
    

提交回复
热议问题