Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:19:19+00:00 2026-05-22T19:19:19+00:00

I have made custom listview in android activity which has progressbar. On top of

  • 0

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.

ProgressBarUpdate

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.

In Layout file I have used LinearLayout where I want to put the bar.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="5dip">
<RelativeLayout android:id="@+id/Top"
    android:layout_centerHorizontal="true" android:layout_width="250dip"
    android:layout_height="wrap_content">
    <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" />
    <RelativeLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_alignParentRight="true">
        <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" />
        <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" />
        <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" />
    </RelativeLayout>
</RelativeLayout>
<RelativeLayout android:id="@+id/Bottom"
    android:layout_below="@+id/Top" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_centerHorizontal="true">
    <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" />
    <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" />
</RelativeLayout>
<RelativeLayout android:id="@+id/Middle"
    android:layout_centerHorizontal="true" android:layout_width="250dip"
    android:layout_height="wrap_content" android:layout_below="@+id/Top">
    <LinearLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/PuttingBar"
        android:layout_alignParentLeft="true">
    </LinearLayout>
</RelativeLayout>
<View android:layout_width="fill_parent" android:layout_height="10dip"
    android:background="#00000000" android:layout_below="@+id/Bottom" />
</RelativeLayout>

In Java I have done something like this.

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<ProgressList> mPList;
private TextView mLeft, mMiddle, mRight, mTextOne;
private ProgressBar mCustomProgressBar;
private LinearLayout mLinearLayout;

public ProgressListAdapter(Context nContext, ArrayList<ProgressList> 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() > mBarPosition)
    {
        mCustomProgressBar.setProgress(mBarPosition);
        mCustomProgressBar.setSecondaryProgress(mEntry.getValueNumber());
    }
    else if(mEntry.getValueNumber() <= 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;
}
}

But When I run It shows extra bar in progress bar like this

ProgressBar

Anybody has done kind of work please give me your hand. Waiting for fruitful reply.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:19:20+00:00Added an answer on May 22, 2026 at 7:19 pm

    You should add call to removeAllViews in your getView funcion:

    mLinearLayout = (LinearLayout) convertView.findViewById(R.id.PuttingBar);
    mLinearLayout.removeAllViews(); 
    View mView = new View(mContext);
    

    That’s because LinearLayout accumulates views, and there might be multiple calls to your addView function. So you need to remove already added view before adding another PuttingBar with new margin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a custom object called students that has two nsstring object. One
I have a custom made collection that has many modes of objects generations inside
I have made a custom control which consists of a richtextbox and a picture
I have made some custom attached properties that enable me to create a pop
I have made a custom UserControl i Vb.net (windows application). How can I add
Coming from this question , I have a wxComboCtrl with a custom popup made
I have made some code which exports some details of a journal article to
I have made a new windows service which works fine using barebone code (just
So I have made a webservice that interfaces with a set of data contained
I have a JavaScript class that I have made and put it into its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.