Android SearchView: redirect to another search activity - android

I have a SearchView (support v7) with custom suggestions. Everything works fine.
But now I want to redirect to another search activity depending on the selected suggestion.
The custom suggestion table contains suggestions and search matches. And when ever the user clicks on a match I want to show the data without the search (because it is a match, no search is needed)
Currently I use the SUGGEST_COLUMN_INTENT_ACTION in the search activity to open the other activity. It works but is this the best way to do this?
Ralph

Related

How can we add a new context menu option to all the apps that would show up when user selects a text and long presses on it?

How can we add a new context menu option to all the apps that would show up when user selects a text and long presses on it?
Let's say I want to provide user the capability of finding the meaning of a word from an offline dictionary without having to navigate away from his app context.
In general to add a context menu we would do a registerForContextMenu on a particular TextView object. Given that this needs to work for all the apps, how do we add context menu options?
How to read the selected text?
How to render a pop-up control on top of the currently open app?
I'm quite new to android development. So any detailed answers or pointers to samples will be of great help. I'm assuming this should be possible to do as the apps "define", "define offline dictionary" seem to do something close to this if not exactly same. In these apps, you can select text and click on copy to see the meaning of the text.
All the search that I have done have shown me examples on how to render a context menu for a text view or how to get selected list item in the context menu handler. But that is not helpful.
Thanks in advance.
I think this can help you, says how to create the Context menu and get the selected text. with that you just need to do a intent to a dictionary giving that selected text as a extra:
https://nitesh.morajkar.com/how-to-select-and-share-text-with-intents-in-android/
And if you want to use for example the google translator for definitions this can help:
Android API support dictionary applications
EDIT: after some search by both the solution for this question is here:
https://medium.com/google-developers/custom-text-selection-actions-with-action-process-text-191f792d2999#.h6377bc8j

ANDROID autoCompleteView suggestions

I want to show suggestions not only as starting character but also a containing character... means 's' suggestions should be like tags,pas,also, and so on.
#sagar jagdale :
You can use Android AutoCompleteTextView.
It provides suggestions automatically when the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
Check Demo Android AutoCompleteTextView Example

Android button auto-fill search field

how can I create in my android app a button that will automatically put the search suggestion into the search bar, so that when you click on the button, the search bar will be automatically filled with the corresponding text?
An example is shown in the image below.
Have you looked into AutoCompleteTextView? From the docs:
The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
EDIT: If you're using a SearchView, the process is much different. Assuming you've already set up the SearchView, you have to provide search suggestions that the system will display as the user types. These can be recent query suggestions or custom search suggestions.
There are several steps involved, but in a nutshell, you will have to create a Content Provider that takes a search query and serves up a list of suggestions (details here). Once you've done this, you can configure your search bar to fill itself in when the user selects a suggestion (details here).
Hope this helps!
The solution is to call setQueryRefinementEnabled(true) on the SearchView object

How to add a drop down next to the search input field in Android?

In the system-wide search on my HTC Desire (Froyo), I see a little drop down left to the search input field that allows to select where I want to search (All, web, apps).
How can I implement this in an application of mine? The search tutorial on the Google developer site does not address this.
So in a scenario like the following, taken from the Android docs,
I would like to click on the books and then get some sort of menu to e.g. select "words", "headings" as search mode.
Update: I am not looking for the QuickAction dialog itself, but rather how to attach something to the books icon that reacts on touch, so that I could attach the QuickAction or a new activity or ... And I want to use the standard Android Search Dialog as described in http://developer.android.com/guide/topics/search/search-dialog.html
You can't modify the system's search dialog. So if you want customizations like making a drop-down menu appear when the user touches the icon, you'll have to implement your own dialog. This would make your search non-standard so I wouldn't advise it.
However, if I can't talk you out of it, you can see how Android's built-in search dialog is implemented here:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/SearchDialog.java
In Android 3.x this gets a little easier with the introduction of the SearchView class.
It is just a custom view that get rendered when you hit that button with a fancy animation.
It has nothing to do with the search framework per se. You just show a custom layout (with a fancy animation if you want) and set a value by clicking on one of the icons. Thats it.
I think what your looking for is called a "quickaction dialog".
Here's a tutorial that should have you well on your way.
Updated by question asker (paste of comment):
ah i see. well somehow you need the id of the icon in order to implement the onclicklistener(). you may be stuck just going with a search widget and implementing most by scratch. Or perhaps, with the search dialog implemented and running, use hierarchyviewer to see if the icon has an id. Maybe you'll be in luck and it'll have a unique one. I'm out of ideas for now.
Those options (and their icons) are determined by the searchable items list in the android settings (Settings->Search->Searchable items at least in my phone). If you want to add a search action to that menu, take a look at this:
http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#QSB
Enabling suggestions on a device
When your application is configured to
provide suggestions in Quick Search
Box, it is not actually enabled to
provide suggestions in Quick Search
Box, by default. It is the user's
choice whether to include suggestions
from your application in the Quick
Search Box. To enable search
suggestions from your application, the
user must open "Searchable items" (in
Settings > Search) and enable your
application as a searchable item.
Each application that is available to
Quick Search Box has an entry in the
Searchable items settings page. The
entry includes the name of the
application and a short description of
what content can be searched from the
application and made available for
suggestions in Quick Search Box. To
define the description text for your
searchable application, add the
android:searchSettingsDescription
attribute to your searchable
configuration. For example:
http://developer.android.com/guide/topics/search/searchable-config.html
Quick Search Box attributes
To make your custom search suggestions
available to Quick Search Box, you
need some of the following
attributes:
android:includeInGlobalSearch
Boolean. (Required to provide search suggestions in Quick Search
Box.) Set to "true" if you want your
suggestions to be included in the
globally accessible Quick Search Box.
The user must still enable your
application as a searchable item in
the system search settings before your
suggestions will appear in Quick
Search Box.
android:searchSettingsDescription
String. Provides a brief description of the search suggestions
that you provide to Quick Search Box,
which is displayed in the searchable
items entry for your application. Your
description should concisely describe
the content that is searchable. For
example, "Artists, albums, and tracks"
for a music application, or "Saved
notes" for a notepad application.
android:queryAfterZeroResults
Boolean. Set to "true" if you want your content provider to be invoked
for supersets of queries that have
returned zero results in the past. For
example, if your content provider
returned zero results for "bo", it
should be requiried for "bob". If set
to "false", supersets are ignored for
a single session ("bob" does not
invoke a requery). This lasts only for
the life of the search dialog or the
life of the activity when using the
search widget (when the search dialog
or activity is reopened, "bo" queries
your content provider again). The
default value is false.
So if you want to add an option to search for words or headings, and you have an activity that allows that search, then you can add that Searchable item(s) to the list. They will be available only if the user wants, though.

Android:Quick Search Box - Adding Custom Suggestions

I am a newbie to android and trying to implement Quick Search Dialog for my application.
Actually, in my application I have an activity
1. where I have a Edit text and Search Button next to it
2. Add Button and a Employee Table below it.
Whenever the user enters the search string in the EditText and clicks the Search button , I am calling the Quick Search Box and luckily it opens with the Search and here the user can see the given search query.
Till this, every thing works perfectly as I want.
But what I want is:
On-Clicking the Search button,the search query is displayed in the QSB and what I want is to display custom suggestions based on the search query and selecting the valid data , it should be saved in the Employee table.
Now I want Custom Suggestions to be displayed in a list view based on the search query.
How do I proceed to achieve this.
Please provide links for Quick search Box custom suggestions also.
Thanks and Regards,
Fazal Ahamed B
This is described here: http://developer.android.com/guide/topics/search/adding-custom-suggestions.html

Categories

Resources