You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加ProgressBar遇错误:CAN NOT RESOLVE SYMBOL LOADING,求代码排查帮助

解决"CAN NOT RESOLVE SYMBOL LOADING"错误(ProgressDialog/ProgressBar相关)

Hey there, let's figure out why you're seeing that "CAN NOT RESOLVE SYMBOL LOADING" error when setting up your progress dialog.

First off, looking at your code:

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

The error has nothing to do with the ProgressBar/ProgressDialog component itself — it's telling you the app can't locate a string resource named loading. Here's how to fix it step by step:

  • Check your res/values/strings.xml file. You either don't have a string entry named loading, or there's a case mismatch (resource names are case-sensitive!)
    • If it's missing, add this line inside the <resources> tag:
      <string name="loading">Loading...</string>
      
      Feel free to replace "Loading..." with any text you want displayed in the progress dialog.
  • If you already have the entry, try cleaning and rebuilding your project:
    • In Android Studio, go to Build > Clean Project, then Build > Rebuild Project. Sometimes cached resource data causes false errors like this.
  • Double-check the spelling: Make sure the name in strings.xml is exactly loading (all lowercase, no typos) to match R.string.loading in your code.

A quick side note: The ProgressDialog class is deprecated in newer Android versions. For better compatibility and Material Design support, you might want to switch to using a ProgressBar inside a custom DialogFragment or the Material Components ProgressIndicator later — but let's get your current code working first!

内容的提问来源于stack exchange,提问作者valdimiro einstein

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:46:48