可以存储最近搜寻的位置由textview
获取文本并将其存储在共享的偏好或数据库。我建议共享偏好though.Then在偏好上AutoCompleteTextview
设定值显示建议:
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String restoredText = prefs.getString("text", null);
if (restoredText != null) {
String name = prefs.getString("name", "No name defined");//"No name defined" is the default value.
int idName = prefs.getInt("idName", 0); //0 is the default value.
}
你可以看看:
// MY_PREFS_NAME - a static String variable like:
//public static final String MY_PREFS_NAME = "MyPrefsFile";
SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit();
editor.putString("name", "Elena");
editor.putInt("idName", 12);
editor.commit();
从偏好数据检索这里:
http://systemout.net/2014/12/19/android-autocomplete-edittext-with-history/
谢谢你的回答。据您所知,有什么方法可以从Google检索您的搜索?我试图避免在我的结尾存储搜索(如果可能)。如果我这样做了,我肯定会使用外部服务器进行存储,因为共享prefs文件对于我的用户执行的搜索量非常大。 –
我怀疑API是否有一种方法,我已经找到了。 虽然你可以限制没有。的建议以编程方式保存在共享偏好或数据库中。 –
很好,谢谢你的帮助。 –