gpt4 book ai didi

java - 强制关闭 onTextChanged

转载 作者:行者123 更新时间:2023-11-29 21:24:27 26 4
gpt4 key购买 nike

我强制关闭,但仅在某些情况下和某些设备上,onTextChanged。这是我写的:

 public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
String text =inputSearch.getText().toString().toLowerCase(Locale.getDefault());
listadaptor.filter(text);
}

日志猫:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dd.androreboot/com.dd.androreboot.applist}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.access$700(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.dd.androreboot.applist$3.onTextChanged(applist.java:104)
at android.widget.TextView.sendOnTextChanged(TextView.java:7822)
at android.widget.TextView.setText(TextView.java:4035)
at android.widget.TextView.setText(TextView.java:3890)
at android.widget.EditText.setText(EditText.java:100)
at android.widget.TextView.setText(TextView.java:3865)
at android.widget.TextView.onRestoreInstanceState(TextView.java:3758)
at android.view.View.dispatchRestoreInstanceState(View.java:12561)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2684)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2684)
at android.view.View.restoreHierarchyState(View.java:12539)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1845)
at android.app.Activity.onRestoreInstanceState(Activity.java:972)
at android.app.ListActivity.onRestoreInstanceState(ListActivity.java:219)
at android.app.Activity.performRestoreInstanceState(Activity.java:944)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1148)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
... 11 more

有什么帮助吗?

最佳答案

试试这个

public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
String text = inputSearch.getText().toString();
if(!text.equals("")){
text = text.toLowerCase(Locale.getDefault());
listadaptor.filter(text);
}
}

关于java - 强制关闭 onTextChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20353335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com