title: How to add elements dynamically in fragment in android
body: <p>I Have a <strong>Fragment</strong>, and i want to add elements (textview, button) dynamically when i <strong>click on Floating Action Button</strong>.</p>
  
  <p>Code:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view = inflater.inflate(R.layout.xyz, container, false);
  
      FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              // new elements on click
  
  
  
              // new elements on click
  
          }
      });
      return view;
  }
  </code></pre>