Search code examples
androidprogress-barprogress

make a progressBar


I want to add a ProgressBar to my project, I get the following error: CAN NOT RESOLVE SYMBOL LOADING.

see below my code, help me plz

 public void showProgressDialog() {
    if (mProgressDialog == null) {
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage(getString(R.string.loading));
        mProgressDialog.setIndeterminate(true);
    }

    mProgressDialog.show();
}

public void hideProgressDialog() {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
    }
}

Solution

  • just press alt + enter in loading and select Create string value resource "loading" and then write the Resource Value of the string, just put in Resource Value: loading

    also inside setMessage you can work with a string like this

    mProgressDialog.setMessage("Loading...");
    

    but is a good practice to use Strings than hardcodeding strings.

    You can follow this images

    First alt + enter into loading

    enter image description here

    Then just write Loading... inside Resource Value

    enter image description here

    Then you can go to your Strings.xml that is inside res - values and see that yoru String is there

    enter image description here