我有一个自定义的ViewGroup:
public class GuiContact extends RelativeLayout {
private ViewGroup content
...
public void onCreate() {
content = (ViewGroup) View.inflate(context, R.layout.contact, this);
...
此组件具有管理其行为的状态机。我现在意识到,如果它有一个每州的一个游说,这个组件将更容易管理。
在每次状态机更改时,是否有一种方法可以反转View.inflate
并使用不同的XML布局再次调用它?
答案 0 :(得分:1)
在您为viewGroup充气的活动中试试这个
((ViewGroup) content.getParent()).removeView(content);