NullPointerException trying to access a String resource

后端 未结 3 979
耶瑟儿~
耶瑟儿~ 2021-01-18 07:56

I have the following /res/values/uris.xml



blahblah         


        
3条回答
  •  时光说笑
    2021-01-18 08:50

    My guess you placed bladderUrl smth like this:

    public class YourActivity extends Activity {
        private String bladderUrl = getString(R.string.bladder);
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
    ...
    

    However you need to do smth like this:

    public class YourActivity extends Activity {
        private String bladderUrl;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            bladderUrl = getString(R.string.bladder);
    ...
    

提交回复
热议问题