PlaceAutocompleteFragment implementation is working fine, as it should work. On Click on PlaceAutocompleteFragment, I am able to search places.
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Toast.makeText(AroundMe.this, "" + place.getName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Status status) {
Toast.makeText(AroundMe.this, "" + status, Toast.LENGTH_SHORT).show();
}
});
Post-click on search result item list, I'm able to get Places details inside onPlaceSelected() method.
Here is what I am looking for:
- On click of PlaceAutocompleteFragment, KeyBoard comes & there is search button on bottom right. I want to handle the event on that search button. But currently on click on search button, keyboard hides.
I have already tried this way, but it's not working.
EditText editText = (EditText) autocompleteFragment.getActivity().findViewById(R.id.place_autocomplete_search_input);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Toast.makeText(AroundMe.this, "check", Toast.LENGTH_SHORT).show();
}
return false;
}
});
Also tried this way, but still it's not working.
EditText editText = (EditText) autocompleteFragment.getActivity().findViewById(R.id.place_autocomplete_search_input);
editText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
if (keyEvent.getAction()== KeyEvent.KEYCODE_SEARCH){
switch (keyCode){
case KeyEvent.KEYCODE_SEARCH:
Toast.makeText(AroundMe.this, "check" , Toast.LENGTH_SHORT).show();
break;
}
}
return false;
}
});