In my android project, I am dynamically adding forms to my linear layout and then destroying them when I am done with a button. However, When I click the "add button" It infinitely adds more forms although I want only one at a time. How can i chec if my linearLayout "accounts" has been added to the view or if it exists in the view at the time? This is the code to add the view. How can I check to see if the view already exists before I add the view?
public void showForm(String form){
View view;
LayoutInflater inflater
=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.forms, null);
LinearLayout item = (LinearLayout) view.findViewById(R.id.accounts);
l.addView(item);
}