title: Android: Add textViews in RelativeLayout Programmatically
body: <p>I have an RelativeLayout and I would like to insert some textViews.</p>
  
  <p>Here is the code:</p>
  
  <pre><code> &lt;RelativeLayout
      android:id="@+id/JournalSearchListView"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:minHeight="30dp"
      android:layout_below="@+id/JournalsSearchTextView"
      android:orientation="vertical" 
      android:cacheColorHint="#00000000"&gt;
  
      &lt;ProgressBar
          android:id="@+id/JournalSearchProgressBar"
          style="?android:attr/progressBarStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And how I am doing this programmatically:</p>
  
  <pre><code>RelativeLayout journals = (RelativeLayout) findViewById(R.id.JournalSearchListView);
  RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
  for (int i=0;i&lt; authorNames.size();i++) {
      TextView tv = new TextView(this);
      tv.setId(i); 
      tv.setText(authorNames.get(i));
      tv.setTextColor(Color.BLACK);
      Integer a = tv.hashCode();
      map.put(a,authorNames.get(i));
      params1.addRule(RelativeLayout.BELOW, tv.getId());
      journals.addView(tv, params1);
      tv.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
               System.out.println("Clicked "+ map.get(v.hashCode()) );    
           }
      });   
  }
  </code></pre>
  
  <p>But the problem is that each textView is in the same position as the others.</p>