title: How to add a view to custom listview in android?
body: <p>I have made custom listview in android activity which has progressbar. On top of that listview there is another progress bar which shows progress as day passes in the month. Now i want to set a bar according to the progress of the month progress bar in custom listview which has four progress bars. Please see the attached image. </p>
  
  <p><img src="https://i.stack.imgur.com/dR0JJ.png" alt="ProgressBarUpdate"></p>
  
  <p>The progress of the month progress bar and the bar which we put in listview progress bar should be at same position means aligned and this bar which we put should move when the top progress increases as day passes.</p>
  
  <p>In Layout file I have used LinearLayout where I want to put the bar.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="wrap_content"
  android:layout_marginTop="5dip"&gt;
  &lt;RelativeLayout android:id="@+id/Top"
      android:layout_centerHorizontal="true" android:layout_width="250dip"
      android:layout_height="wrap_content"&gt;
      &lt;TextView android:id="@+id/LeftText" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="O"
          android:textColor="#FFFFFF" android:textStyle="normal"
          android:layout_alignParentLeft="true" /&gt;
      &lt;RelativeLayout android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:layout_alignParentRight="true"&gt;
          &lt;TextView android:id="@+id/TextOne" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:text="O"
              android:textColor="#FFFFFF" android:textStyle="normal"
              android:layout_marginRight="5dip" /&gt;
          &lt;TextView android:id="@+id/TextTwo" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:text="@string/outof"
              android:textColor="#FFFFFF" android:textStyle="normal"
              android:layout_toRightOf="@+id/TextOne" android:layout_marginRight="5dip" /&gt;
          &lt;TextView android:id="@+id/RightText" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:text="O"
              android:textColor="#FFFFFF" android:textStyle="normal"
              android:layout_toRightOf="@+id/TextTwo" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/RelativeLayout&gt;
  &lt;RelativeLayout android:id="@+id/Bottom"
      android:layout_below="@+id/Top" android:layout_width="wrap_content"
      android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;
      &lt;ProgressBar android:id="@+id/CustomPro"
          android:layout_width="250dip" android:layout_height="wrap_content"
          android:progress="0" android:max="100" android:secondaryProgress="0"
          style="?android:attr/progressBarStyleHorizontal"
          android:progressDrawable="@drawable/accountdataprogress"
          android:layout_centerHorizontal="true" /&gt;
      &lt;TextView android:id="@+id/MiddleText" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="0%"
          android:textColor="#000000" android:textStyle="bold"
          android:layout_centerHorizontal="true" /&gt;
  &lt;/RelativeLayout&gt;
  &lt;RelativeLayout android:id="@+id/Middle"
      android:layout_centerHorizontal="true" android:layout_width="250dip"
      android:layout_height="wrap_content" android:layout_below="@+id/Top"&gt;
      &lt;LinearLayout android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:id="@+id/PuttingBar"
          android:layout_alignParentLeft="true"&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  &lt;View android:layout_width="fill_parent" android:layout_height="10dip"
      android:background="#00000000" android:layout_below="@+id/Bottom" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In Java I have done something like this.</p>
  
  <pre><code>import java.util.ArrayList;
  
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.ProgressBar;
  import android.widget.TextView;
  
  public class ProgressListAdapter extends BaseAdapter 
  {
  private Context mContext;
  private ArrayList&lt;ProgressList&gt; mPList;
  private TextView mLeft, mMiddle, mRight, mTextOne;
  private ProgressBar mCustomProgressBar;
  private LinearLayout mLinearLayout;
  
  public ProgressListAdapter(Context nContext, ArrayList&lt;ProgressList&gt; nPList) 
  {
      this.mContext = nContext;
      this.mPList = nPList;
  }
  
  @Override
  public int getCount() 
  {
      return mPList.size();
  }
  
  @Override
  public Object getItem(int nPosition) 
  {
      return mPList.get(nPosition);
  }
  
  @Override
  public long getItemId(int nPosition) 
  {
      return nPosition;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) 
  {
      ProgressList mEntry = mPList.get(position);
      if (convertView == null) 
      {
          LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = mInflater.inflate(R.layout.customprogress, null);
      }
  
      mLeft = (TextView) convertView.findViewById(R.id.LeftText);
      mLeft.setText(mEntry.getValueText());
  
      mMiddle = (TextView) convertView.findViewById(R.id.MiddleText);
      mCustomProgressBar = (ProgressBar) convertView.findViewById(R.id.CustomPro);
      int mBarPosition = Usage.mElapsed;
  
      mLinearLayout = (LinearLayout) convertView.findViewById(R.id.PuttingBar);
      View mView = new View(mContext);
      LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(2, 25);
      layoutParams.setMargins(mBarPosition, 0, 0, 0);
      mView.setMinimumHeight(25);
      mView.setMinimumWidth(2);
      mView.setBackgroundColor(Color.rgb(12, 56, 99));
      mLinearLayout.addView(mView, layoutParams);
      mView.invalidate();
  
      if(mEntry.getValueNumber() &gt; mBarPosition)
      {
          mCustomProgressBar.setProgress(mBarPosition);
          mCustomProgressBar.setSecondaryProgress(mEntry.getValueNumber());
      }
      else if(mEntry.getValueNumber() &lt;= mBarPosition)
      {
          mCustomProgressBar.setProgress((mEntry.getValueNumber()));
          mCustomProgressBar.setSecondaryProgress(0);
      }
      mMiddle.setText(Integer.toString(mEntry.getValueNumber()) + "%");
  
      mTextOne = (TextView) convertView.findViewById(R.id.TextOne);
      mTextOne.setText(mEntry.getValue());
      mRight = (TextView) convertView.findViewById(R.id.RightText);
      mRight.setText(mEntry.getValueOne());
  
      return convertView;
  }
  }
  </code></pre>
  
  <p>But When I run It shows extra bar in progress bar like this </p>
  
  <p><img src="https://i.stack.imgur.com/TUj7g.png" alt="ProgressBar"></p>
  
  <p>Anybody has done kind of work please give me your hand. Waiting for fruitful reply.
  Thanks.</p>