title: Adding a textview dynamically in fragment
body: <p>I am new in android development..I am working with fragment.The problem i am facing right now is-I can't add view dynamically in fragment.When I tried to do this I got a nullpointerexception...My code snippet is as follows:</p>
  
  <pre><code>final LinearLayout linearLayout = (LinearLayout)inflater.inflate(R.layout.connections_layout, container, false);
  EditText editText = new EditText(getActivity());
  
  final int i = 5;
  editText.setId(i); //Set id to remove in the future.
  editText.setLayoutParams(new LayoutParams(
          LayoutParams.FILL_PARENT,
          LayoutParams.WRAP_CONTENT));
  editText.setText("Hello");
  Log.d("View","Start");
  try{
      linearLayout.addView(editText);
  }catch(Exception e){
      e.printStackTrace();
  }
  </code></pre>
  
  <p>The <strong>connection_layout.xml</strong> file is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                        android:id="@+id/connections"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:background="#FF0000" &gt;
  
    &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The fragment is a member of a tabgroup that belongs to fragment activity.What am i doing wrong in my code snippet? Any kind of help is appreciated.Thanks in advance...</p>