Percentage Not showing in progressBar

VijayPratapVijayPratap INMember ✭✭

Dear all,
we are creating a offline Application where data transfer on button click. we want to create a progress bar with percentage on button click. progress bar is working but percentage is not showing.this is my code.

<ProgressBar

style="?android:attr/progressBarStyleHorizontal"

android:id="@+id/progressBar1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity="center" />

    async void buttonSyncronizeClicked(object sender, EventArgs e)
    {
        try
        {
            progressBar.Visibility = ViewStates.Visible;
            progressBar.Indeterminate = true;
            await myMethod()
            progressBar.Visibility = ViewStates.Invisible;
        }
        catch
        { }
    }

    async Task myMethod()
    {
        await Task.Run(() => {
            string strSyncLogStatus = database.Global.strUserId + DateTime.Now.ToString("ddMMyyyyhhmmss");
            database.Global.syncErrorExists = false;
            result = baseObj.syncTablesStructures();
            result += baseObj.insertSyncLog(result);
        });
    }

How to achieve percentage in progressbar please suggest.

Answers

  • N_BauaN_Baua INMember ✭✭✭✭✭
    edited May 2017

    Hi Vijay,

    Try something like this..

    Sure you code can update a label .

    Regards,
    N Baua

  • VijayPratapVijayPratap INMember ✭✭

    Hi Nhilesh,
    I Cant Understand please explore.

  • N_BauaN_Baua INMember ✭✭✭✭✭

    @VijayPratap said:
    Hi Nhilesh,
    I Cant Understand please explore.

    The default progress-bar control will not display the percentage text (as in C# control).
    You will have to use additional label control for the same and update the progress value.
    When task is done simply clear the text(optional).

    so


    While your C# code can expose some bind-able property TaskPercentComplete and myMethod can update the value based on your code execution (say in beginning 0% and upon finishing 100%).

    Hope this helps

    Regards,
    N Baua

Sign In or Register to comment.