Java performFiltering()-AutoCompleteTextView期间发生异常
我有一个自动完成的文本视图,它无法通过字符串数组进行过滤。正如在其他帖子中建议的那样,我彻底检查了数组中是否有空值,但没有空值 这就是我得到的错误Java performFiltering()-AutoCompleteTextView期间发生异常,java,android,android-studio,autocomplete,autocompletetextview,Java,Android,Android Studio,Autocomplete,Autocompletetextview,我有一个自动完成的文本视图,它无法通过字符串数组进行过滤。正如在其他帖子中建议的那样,我彻底检查了数组中是否有空值,但没有空值 这就是我得到的错误 java.lang.NullPointerException at android.widget.ArrayAdapter$ArrayFilter.performFiltering(ArrayAdapter.java:480) at android.widget.Filter$RequestHandler.handleMessage(Filt
java.lang.NullPointerException
at android.widget.ArrayAdapter$ArrayFilter.performFiltering(ArrayAdapter.java:480)
at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:61)
下面是我的代码
DataUsageController duc = new DataUsageController(context);
String costCentreString = duc.costCentreString;
String[] strs = costCentreString.split(",,");
String[]costCentreList = new String[costCentreString.length()];
for (int i=0; i < strs.length ; i++) {
costCentreList[i] = strs[i];
}
et_client=(AutoCompleteTextView)findViewById(R.id.et_client);
AutoCompleteTextView actv = (AutoCompleteTextView)findViewById(R.id.et_client);
actv.setAdapter(new ArrayAdapter<String>(this, R.layout.costcentrelist__details, costCentreList));
et_client=(AutoCompleteTextView)findViewById(R.id.et_client);
actv.setAdapter(new ArrayAdapter<String>(this, R.layout.costcentrelist__details , costCentreList));
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this,android.R.layout.select_dialog_item,costCentreList);
DataUsageController-duc=新的DataUsageController(上下文);
字符串costCentreString=duc.costCentreString;
字符串[]strs=costCentreString.split(“,”);
String[]costCentreList=新字符串[costCentreString.length()];
对于(int i=0;i
这是我在XML中自动完成的文本视图
<AutoCompleteTextView
android:id="@+id/et_client"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</AutoCompleteTextView>
设置适配器后,为什么会有此ArrayAdapter adapter=new ArrayAdapter(此,android.R.layout.select_dialog_项,costCentreList)代码>?为什么一个自动完成文本视图有两个参考?一个是本地的,一个是本地的global@Raghunandan谢谢你指出这一点,让我把那一行删掉,看看发生了什么我把那一行删掉了,但我还是得到了同样的错误检查costCentreList
array的内容如果它有null
sOnce你设置了适配器为什么有这个ArrayAdapter=newarrayadapter(这是android.R.layout.select\u dialog\u item,costCentreList)代码>?为什么一个自动完成文本视图有两个参考?一个是本地的,一个是本地的global@Raghunandan谢谢你指出这一点,让我去掉那一行,看看发生了什么我去掉了那一行,但我仍然得到同样的错误检查costCentreList
数组的内容,如果它有null
s