added custom behaviour for search button
This commit is contained in:
parent
2e3ab26c85
commit
ecb963b850
2 changed files with 22 additions and 0 deletions
|
@ -14,6 +14,8 @@
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:hint="@string/search_poi_category_hint"
|
android:hint="@string/search_poi_category_hint"
|
||||||
|
android:imeOptions="actionSearch"
|
||||||
|
android:inputType="text"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColor="?attr/searchbar_text"
|
android:textColor="?attr/searchbar_text"
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.search;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -25,10 +26,13 @@ import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -523,6 +527,22 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
);
|
);
|
||||||
|
|
||||||
searchEditText = (EditText) view.findViewById(R.id.searchEditText);
|
searchEditText = (EditText) view.findViewById(R.id.searchEditText);
|
||||||
|
searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
|
searchQuery += " ";
|
||||||
|
searchEditText.clearFocus();
|
||||||
|
InputMethodManager im = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (im != null) {
|
||||||
|
im.hideSoftInputFromWindow(searchEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
runSearch();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
searchEditText.addTextChangedListener(
|
searchEditText.addTextChangedListener(
|
||||||
new TextWatcher() {
|
new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue