2013-07-01 43 views
1

我在我的應用程序中有一個AutoCompleteTextView,我正在使用CursorLoader加載數據。顯然有一些問題,使用這種方法的數據加載,因爲時不時我不斷收到此錯誤:光標加載器觀察者已註冊錯誤

07-01 11:17:49.209: E/AndroidRuntime(20758): java.lang.IllegalStateException: Observer 
[email protected] is already registered. 

沒有人有這樣的問題呢?

回答

2

我似乎已經解決了這個問題。只有當我從AutoCompleteTextView的自動完成列表中執行項目單擊時,我纔有這種崩潰(錯誤)。這個錯誤顯然是內部的,它與我曾用作我的AutoCompleteTextViewAdapter的CursorAdapter的內部觀察者有關。所以現在,在每一個項目點擊,我做如下:

txtAutocomplete.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { 
       // ... your code here ... 
       autocompleteContactsAdapter.changeCursor(null); 
      } 
     } 
    }); 

現在我的應用程序不會崩潰。