开发者

Android: ProgressDialog crashes when use resources to initialize the message

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜