尝试在空对象引用上调用虚拟方法'voidfilteredList(java.util.ArrayList)'

时间:2019-07-24 14:54:49

标签: java android arraylist nullpointerexception

public voidfilteredList(ArrayList filterList){

    myCareList = filterList;
    notifyDataSetChanged();

}

private void filter(字符串文本){

    ArrayList<CareTakerData> filterList= new ArrayList<>();


    for(CareTakerData detail:myCareTakerList) {



        if(detail.getCaretakerLocation().toLowerCase().contains(text.toLowerCase())) {

            filterList.add(detail);


        }
    }

    myAdapter.filteredList(filterList);

}

@Override                 public void afterTextChanged(Editable editable){

                filter(editable.toString());

            }
        });

java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void com.example.pethut.MyAdapter.filteredList(java.util.ArrayList)'         在com.example.pethut.LocationActivity.filter(LocationActivity.java:151)         在com.example.pethut.LocationActivity.access $ 000(LocationActivity.java:23)         在com.example.pethut.LocationActivity $ 2.afterTextChanged(LocationActivity.java:123)         在android.widget.TextView.sendAfterTextChanged(TextView.java:9375)         在android.widget.TextView $ ChangeWatcher.afterTextChanged(TextView.java:11917)         在android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1262)         在android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:574)         在android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:504)         在android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:502)         在android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:843)         在android.view.inputmethod.BaseInputConnection.setComposedText(BaseInputConnection.java:616)         在com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:396)         在com.android.internal.view.IInputConnectionWrapper $ MyHandler.handleMessage(IInputConnectionWrapper.java:85)         在android.os.Handler.dispatchMessage(Handler.java:105)         在android.os.Looper.loop(Looper.java:164)         在android.app.ActivityThread.main(ActivityThread.java:6541)         在java.lang.reflect.Method.invoke(本机方法)         在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

0 个答案:

没有答案