开发者

Android: ProgressDialog crashes when use resources to initialize the message

开发者 https://www.devze.com 2023-03-03 18:40 出处:网络
When I use this code: public class VideoSorveglianza extends Activity { private ProgressDialog mLoading;

When I use this code:

public class VideoSorveglianza extends Activity {

  private ProgressDialog mLoading;

      ...

      @Override
      public void onCreate(Bundle savedInstanceState) {

      ...

      mLoading = new ProgressDialog(this);
      mLoading.setMessage("Loading");
      ...
}

All works fine. But开发者_运维技巧 If I try this:

mLoading.setMessage(getString(R.string.loading));

with the string declared in res/string.xml, nothing works!

Is this a bug? I use API version 2.2.

EDIT: my string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<string name="loading">Loading...</string>
...
</resources>


Use getResources().getString(R.string.loading) in mLoading.setMessage()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号