title: Adding array of textviews dynamically to linear layout
body: <p>I tried to add an array of textviews which i defined as a public variable, but when i run the application, it force closes as soon as it gets into for loop. This is the code:</p>
  
  <pre><code>LinearLayout myLayout = (LinearLayout) findViewById(R.id.my_layout);
              LayoutParams lp = new LayoutParams( LayoutParams.WRAP_CONTENT,    LayoutParams.WRAP_CONTENT);
              pairs=new TextView[num_match+1];
              for(int l=1;l&lt;=num_match;l++)
              {
                  pairs[l].setTextSize(15);
                  pairs[l].setLayoutParams(lp);
                  pairs[l].setId(l);
                  pairs[l].setText(m1[l]+" - "+m2[l]);
                  myLayout.addView(pairs[l]);
              }
  </code></pre>