-1

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();
    }
}

3 Answers3

0

This error is caused because it can´t find the string loading from the resources, check if it´s correctly spelled if it´s try to re-build the gradle and the sync the project.

JJaviMS
  • 392
  • 6
  • 18
0

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

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
0

You can enter direct text here

mProgressDialog.setMessage("Your Text");