title: How to dynamically add a TableRow in a Fragment?
body: <p>I am new in Android programming, currently I am trying to insert a textview inside the table layout dynamically in fragment. It worked while extending the class to Activity. Below is my code snippet. Am I missing something?</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_schedule, null);
      TableLayout ll = (TableLayout) getActivity().findViewById(R.id.tableLayout1);
      TableRow tr= new TableRow(getActivity());
      TextView tv1 = new TextView(getActivity());
      tv1.setText("TEST NUMBER");
      tv1.setTextColor(Color.WHITE);
      tv1.setTextSize(20);
      tv1.setPadding(5, 5, 5, 5);
      tr.addView(tv1);
      ll.addView(tr);
      return view;
  }
  </code></pre>
  
  <p>Thank you in advance.</p>