当前位置:   article > 正文

Android --- Argument must not be null解决

argument must not be null
aused by: java.lang.NullPointerException: Argument must not be null
        at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:31)
        at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:25)
        at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:685)
        at com.gxuwz.pet.activity.AddPetLossActivity.onActivityResult(AddPetLossActivity.java:130)
        at android.app.Activity.dispatchActivityResult(Activity.java:6192)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3575)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3622) 
        at android.app.ActivityThread.access$1300(ActivityThread.java:153) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5307) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

没有初始化控件在这里插入图片描述要findViewById找到控件

注意:一定要将找到控件放到初始化视图的后面,如下面的例子就是错误的

   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);// Activity 中去掉标题栏
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE); // AppCompatActivity 中去掉标题栏
        // 标题栏和状态栏颜色一致
        StatusBarUtils.setColor(MyOrganInfoActivity.this);

        initView();
        initData();
        initEvent();

        setContentView(R.layout.activity_my_organ_info);
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

正确为:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);// Activity 中去掉标题栏
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE); // AppCompatActivity 中去掉标题栏
        // 标题栏和状态栏颜色一致
        StatusBarUtils.setColor(MyOrganInfoActivity.this);

        setContentView(R.layout.activity_my_organ_info);

        initView();
        initData();
        initEvent();

    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/500532
推荐阅读
  

闽ICP备14008679号