title: Custom ListView Items repeated
body: <p>I am trying to add dynamic textview to listview items.textviews can be of 1-2 or more than that depending on data I have succeed in adding the textview but problem is textviews are repeated on scroll.</p>
  
  <p>I am creating new object of textview each time in loop.I am aware of the problem that android tries to reuse existing view but i have to add new view every time.</p>
  
  <p>Here is my code in custom adapter:</p>
  
  <pre><code>public class ViewHolder {
      TextView text1;
      LinearLayout linearLayout;
      TextView t;
      TextView t1;
  }
  </code></pre>
  
  <p>getView method</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  
      ViewHolder holder;
  
      if (convertView == null) {
          convertView = mInflater.inflate(R.layout.two_item_icon_text, null);
          holder = new ViewHolder();
          holder.text1 = (TextView) convertView.findViewById(R.id.text1);
  
          convertView.setTag(holder);
      } else {
  
          holder = (ViewHolder) convertView.getTag();
  
      }
  
      holder.linearLayout = (LinearLayout) convertView.findViewById(R.id.lin_lay_dynamic);
      holder.text1.setText("" + DATA1[position]);
      String tmp, dateparsed;
      dateparsed = DATA1[position].substring(0, DATA1[position].indexOf(":"));
      for (int x = 0; x &lt; calendareventholder1.size(); x++) {
  
          objHolder = (CalendarEventHolder) calendareventholder1.get(x);
  
          if (objHolder.opendate.equals(displaydate[current])) {
  
              tmp = objHolder.dtstarttime.toString().substring(0, objHolder.dtstarttime.toString().indexOf(":"));
  
              if (Integer.parseInt(tmp) &gt;= Integer.parseInt(dateparsed) &amp;&amp; Integer.parseInt(tmp) &lt; Integer.parseInt(dateparsed) + 1) {
                  holder.t = new TextView(convertView.getContext());
                  holder.t.setText(":-d ");
                  holder.t.setOnClickListener(this);
  
                  if (Common.isChildSessionAlerted(String.valueOf(objHolder.id), getApplicationContext(), object1)) {
  
                      holder.t.setText(holder.t.getText() + objHolder.dtstarttime + " " + objHolder.dtendtime + " :-a");
                  } else {
                      holder.t.setText(holder.t.getText() + objHolder.dtstarttime + " " + objHolder.dtendtime);
                  }
                  holder.t.setTag(objHolder.id);
                  holder.t.setTextSize(Common.getPreferenceInt(getApplicationContext(), Common.PREF_FONT_SIZE, 10));
                  holder.t.setTextColor(Color.BLACK);
                  holder.t.setText(getSmiledText(ScheduleActivity.this,
                  holder.t.getText().toString()));
                  holder.linearLayout.addView(holder.t);
                  holder.t1 = new TextView(convertView.getContext());
                  holder.t1.setOnClickListener(this);
                  holder.t1.setText(objHolder.title);
                  holder.t1.setTag(objHolder.id);
  
                  holder.t1.setTextSize(Common.getPreferenceInt(getApplicationContext(), Common.PREF_FONT_SIZE, 10));
                  holder.t1.setTextColor(Color.BLACK);
                  holder.linearLayout.addView(holder.t1);
              }
          }
      }
      return convertView;
  }
  </code></pre>