11-06 19:52:25.958: E/AndroidRuntime(29609): java.lang.IllegalStateException: 适配器的内容已更改,但 ListView 未收到通知。确保适配器的内容不是从后台线程修改的,而只是从 UI 线程修改的。[在 ListView(-1, class android.widget.ListPopupWindow$DropDownListView) with Adapter(class com.example.parkfoxxlight_android.PlacesAutoCompleteAdapter)]
完整日志: http: //pastebin.com/Hx7k28Rm
适配器的完整代码:http: //pastebin.com/TfH1bXE3我正在使用来自https://developers.google.com/places/training/autocomplete-android的示例,它具有相当的默认代码,所以似乎有一个谷歌代码中的错误?
该应用程序仅有时会因上述错误消息而崩溃。
protected void publishResults(CharSequence constraint,
FilterResults results) {
if (results != null && results.count > 0) {
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}
活动http://pastebin.com/FYzYtvXY:
public class CityActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.city);
AutoCompleteTextView autoCompView = (AutoCompleteTextView) findViewById(R.id.autocomplete_city);
PlacesAutoCompleteAdapter ad = new PlacesAutoCompleteAdapter(this);
ProgressBar b = (ProgressBar)findViewById(R.id.progressBar1);
ad.setLoadingIndicator(b);
autoCompView.setAdapter(ad);
}
}
任何想法如何解决这一问题?我在安卓 4.3 上。