当我按下一个按钮时,我希望出现一个膨胀视图,当我按下同一个按钮时,这个视图消失......
ViewGroup parent = (ViewGroup) findViewById(R.id.inflate_place);
View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.inflate_find, null);
for(int i=0; i<parent.getChildCount(); ++i) {
View nextChild = parent.getChildAt(i);
// Here i want that if is the same layout, this disappear
if (nextChild.equals(view)) {
parent.removeView(nextChild);
return;
}
}
parent.addView(view);