title: how to create dynamic listview and set visibility of Textview
body: <p>I'm new to Android development. I successfully created a demo project with a dynamic listview but now my problem is that I have two textviews in my <code>list_row</code> xml file.</p>
  
  <p>Textview2 is default hide(Visibility=Gone). </p>
  
  <p>Now I set the visibility of that textview visible only in fifth position in listview. I wrote code for that but the textview shows up randomly, not just in the fifth position. I have 100 records in the listview.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) 
  {
      // TODO Auto-generated method stub
      ViewHolder holder;
  
      if (convertView == null) 
      {
          convertView = mLayoutInflater.inflate(R.layout.list_row, null);
          holder = new ViewHolder();
          holder.text1 = (TextView) convertView.findViewById(R.id.mytext);
          holder.text2 = (TextView) convertView.findViewById(R.id.invisibletext);
          convertView.setTag(holder);
          if (position == 5) 
              holder.text2.setVisibility(View.VISIBLE);
          else
              holder.text2.setVisibility(View.GONE);
      } 
      else 
      {
          holder = (ViewHolder) convertView.getTag();
      }
  
      return convertView;
  }
  
  static class ViewHolder 
  {
      TextView text1;
      TextView text2;
  }
  </code></pre>