Android --- 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) 

没有初始化控件Android --- Argument must not be null解决_第1张图片要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);
    }

正确为:

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

    }

你可能感兴趣的:(Android,项目开发笔记,Argument,mu,st,not,be,null)