android dynamically add element from layout xml

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

How can I take the element myButton from this layout xml




        
相关标签:
2条回答
  • 2021-01-04 14:51

    Need to ask R.id.mainLayout Linear Layout is in other xml file or the same ?

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题