performFiltering() - AutoCompleteTextView期间发生异常

时间:2016-09-21 07:33:55

标签: java android android-studio autocomplete autocompletetextview

我有一个自动完整的文本视图,它以某种方式无法过滤字符串数组。正如在其他帖子中所建议的那样,我彻底检查了我的数组中是否有任何空值但没有。

这是我得到的错误

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

这是我在XML中的自动完成TextView

<AutoCompleteTextView
        android:id="@+id/et_client"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
     </AutoCompleteTextView>

0 个答案:

没有答案