I use an ArrayList and an ArrayAdapter to log down the contents of AutoCompleteTextView, and I want to dynamically refresh the AutoCompleteTextView when the list is modified. The modification of the list is triggered in a webviewClient.
However, my code doesn't work. The AutoCompleteTextView can only be updated when the whole activity is reloaded. There is no dynamic update at all. Could anyone help me to find out what was wrong?
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, mHistory); //mHistory is the list of data
adapter.setNotifyOnChange(true);
mEditText1.setAdapter(adapter); //mEditText1 is the AutoCompleteTextView
mWebView1.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url){
super.onPageFinished(view, url);
if (!mHistory.contains(mWebView1.getUrl())){
mHistory.add(mWebView1.getUrl());
writeList(view.getContext(), mHistory, "history"); //this is to store the list elsewhere
}
adapter.notifyDataSetChanged();
}
});