Use circular progress bar as alertdialog or progressdialog

I use this library to create a circular progress bar for my android wear ( https://github.com/lzyzsd/CircleProgress ). I created a layout that defines circular progress.

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:background="#000000"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:id = "@+id/progress_layout_id">
    <com.github.lzyzsd.circleprogress.ArcProgress
        android:id="@+id/m_arc_progress"
        android:layout_width="214dp"
        android:layout_height="match_parent"
    />

</LinearLayout>

I want this layout in which the round Progressbar to be defined to display as alertdialog or progress dialog. I was able to do this. This is the code for this.

public class progressbar_fragment extends AlertDialog {
    ArcProgress m_arc;
    View v;
    int mProgressVal;
    Context mContext;

    protected progressbar_fragment(Context context) {
    super(context);
    mContext = context;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    m_arc = (ArcProgress) findViewById(R.id.m_arc_progress);


    if (mProgressVal > 0) {
        setProgress(mProgressVal);
    }
}

@Override
public void show() {
    super.show();
    setContentView(R.layout.pogress_bar);
}

And I call it in the class file as

    m_arc = new progressbar_fragment(m_caller_context);
    m_arc.show();

So, the circular progress indicator is displayed as alertdialog. Now I want to set the progress when it goes through the code. Can someone please call me how I can make this progress function is in the library code.

There must be a way like

m_arc_progress = (ArcProgress) l_progress_layout.findViewById(R.id.m_arc_progress);
    m_arc_progress.setProgress(0);

,

m_arc_progress.setProgress(25);

> java.lang.NullPointerException: Attempt to invoke virtual method
> 'android.view.View android.view.Window.findViewById(int)' on a null
> object reference

, , .

+4
1

setContentView(R.layout.pogress_bar); , onCreate(), findViewById

+1

All Articles