From 87c5025fb8a21348ead7cd7e6fa08aa5dc0f501e Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Thu, 21 Oct 2010 21:16:42 -0700 Subject: Moving cursor to the end of the search query when set explicitly. This situation is encountered in Contacts when the activity intercepts unsolicited input from the keyboard, takes that character entered by the user and switches the whole app to "search mode". At this time it puts the character entered by the user in the search field. The user should be able to continue typing. Change-Id: Ief40f12bb8f31bced6114d61a0fd95472f21b1be --- core/java/android/widget/SearchView.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'core/java/android/widget/SearchView.java') diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 1d36b49297fe..029aebfe2041 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -306,6 +306,10 @@ public class SearchView extends LinearLayout { */ public void setQuery(CharSequence query, boolean submit) { mQueryTextView.setText(query); + if (query != null) { + mQueryTextView.setSelection(query.length()); + } + // If the query is not empty and submit is requested, submit the query if (submit && !TextUtils.isEmpty(query)) { onSubmitQuery(); -- cgit v1.2.3