android app search button - android

I've been trying to make my app implement the built in quick search, similar to how it is done in ApiDemos' "app/search/invoke search". I have tried everything from trying to follow different examples, to copying the code exactly as it is in ApiDemos.
All I've found for the former have been concerned with older versions of the SDK, and simply not worked. As for the stuff that I can actually run and see working in ApiDemos, I've tried copying the following
com.example.android.apis.app.SearchInvoke.java
com.example.android.apis.app.SearchQueryResults.java
com.example.android.apis.app.SearchSuggestionSampleProvider.java
res/layout/search_invoke.xml
res/layout/search_query_results.xml
res/values/arrays.xml
res/values/strings.xml
res/xml/searchable.xml
... and everything under "Search Samples" in AndroidManifest.xml
This copying gets me a view that looks exactly like the one I'm facing when running ApiDemos, but when I click the search button, in the quick search box, Android always just opens up a browser window, with Google search results for the given query. I simply cannot find the critical component in ApiDemos that tells android that I want to use my own custom code for handling the search request.
I would really appreciate some help in this matter. Both documentation and other online resources seem very lacking when it comes to this.
Thanks.

For reference, four months (and god knows how many attempts) later, I've found the part of the documentation I've missed out on, that had the whole search box behave fire up browser search results, instead of passing them to my own activity. It all comes down to a little notice found here:
Note that all user-visible strings must be provided in the form of "#string" references. Hard-coded strings, which cannot be localized, will not work properly in search metadata.

Try reading this first. If that does not help, you can try looking at the search example from one of my books -- that example integrates with the Quick Search Box, and perhaps it will give you more clues.

In addition to the examples provided by commonsware.com, you can look at the Searchable Dictionary in the samples directory of the 1.6 SDK.
http://developer.android.com/guide/samples/SearchableDictionary/index.html

I was wrong before... the SDK documentation has a thurough explanation in the docs for SearchManager that I suggest you take a look at. In addition, as CommonsWare mentioned, the blog entry is also a good resource.

Related

Does anyone know how I could implement "tags" in my Android app similarly to how StackOverflow allows you to add tags?

I have researched this extensively but the only thing I have found for Android is EditTag which only uses preset tags. I want the user to be able to type in a box, and then when they hit space, it creates the last word as a tag. The idea is then for these tags to be searchable. Does anyone know if such a library exists or how I can get started implementing these?
I recommend you take a look at this library https://github.com/2dxgujun/AndroidTagGroup
I'm using it and it is very simple. You can do things like this:

Android Source Codes, Custom Controls, Open Source Libraries

As I was googling, I found lot of codes and libraries. But all of them
are on different sites and could not find any managed site.
like for iPhone : http://cocoacontrols.com/
Is there any such site where I can find codes for Custom Controls..
I know some of top favourite like github.com, anddev.org and Im following too.
Please reply any such site that you found useful.
Thanks
hie vishal, I don't think there is any specific site wherein you can find custom coding source codes. But yes the top favorite list that you have specified indeed have lot of in it.
Secondly, apart from those there are many other sites like
http://blog.pocketjourney.com/2008/03/15/tutorial-1-transparent-panel-linear-layout-on-mapview-google-map/
http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/
and many more according to your requirements. You can learn and take their references for your requirement.
There is a lot more on the developer site for styles and themes which can definately make use off.
Hope this is what you were looking for.

implementing search in the header so as to function in all the screens

I am a newbie to android and apologise if my question is silly. I looked through the net and did not find any proper solution for this.
I want to implement a search function where my edittext is in the header and I want to implement this search function in all the screens with the same functionality. The functionality here is typeahead.
It will be great if I can get some reference to some reading materials which would help me in this or a short hint in any way that can be helpful.
Thanks for your help. I tried it but could not get it working as my activity is not launched. I invested quite a bit of time but did not get through. Is it possible to get a dummy code or prototype with one screen somewhere online so that I can build up on that?
If you want to use the standard Android search interface (which pops up with an edittext in most apps), you'll want to check out search on the Android Developers website. It's a really useful article and worth reading through. If you want the functionality in all the activities, do as it says and put the android.app.default_searchable meta-data tag in the <application> element, not just each <activity> one.

Where to find Android Development Homework Problems

Ok so I am starting off with android development and I have found a bunch of useful tutorials so I am set there. What I am looking for is a resource that provides homework style problems to do and has the answers downloadable so I can check my solution against the "official" solution.
So for example instead of the notepad tutorial it would be: "Build an application that you can create, edit, delete notes, ...etc.". Ideally the "official" solution would have some explanation as to why they built it the way they did. (so a tutorial at the tail end)
Anyone know of any resources that provide their tutorials in this format?
Thanks.
Okay, here's one: build me an app that allows the user to make, modify, and store notes. The 'official' answer is the Notepad app in the 9th level of the api. (Note that this is different from the notepad tutorial).
The point is that asking questions is easy, the harder part is actually making a program that does the job. And #Roflecoptr is right, at this level it can be implemented very differently. But if you want that mindset, you can write your own 'homework' easily. Just think up a few things you want that are simple, build it, does it do what you want well? Then you pass.
Despite for very trivial problems I dont think this is possible, because there are way to much possible implementation possibilites so that you can't compare your solution to the "official" solution.
But why do you need something like that? If you want to learn to program on Android, you can just follow some tutorials you've already found and then modify them, adapt them to your needs. When you get more used to the development of Android apps you can just get some ideas on tutorials/android development sites and then implement your own solution. There is plenty of help available here on SO and on other development sites, which will help you if you really get stuck.
You could always go to the Android Samples page, and without looking at their implementations, do your own and compare. The samples page is here:
http://developer.android.com/resources/samples/index.html

Android Quick Actions UI Pattern

I'm interested in incorporating the Android UI pattern called "Quick Action". Basically, it's a context menu that doesn't cover up the data that is being acted on. I'd like to implement this but I cannot find some sample code or an API to help me out.
Note this UI pattern is discussed in the YouTube video, http://www.youtube.com/watch?v=M1ZBjlCRfz0#t=15m20s.
Does anyone have an implementation of this or know what Google's standard is for adding this to an application?
Till the official Twitter app is open sourced by Google, you may want to take a look at this implementation:
http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
Really easy to use and works great.
Interesting Question. Android uses this pattern in their Contacts-App. You can get the source using git:
git clone git://android.git.kernel.org/platform/packages/apps/Contacts.git
I did this and quickly grepped it, but I didn't get a conclusive result. I think that's done in "Contacts/src/com/android/contacts/ui/QuickContactWindow.java", but I am not completely sure.
I you google for QuickContact android, there are a lot of images that show exactly the kind of menu that you want, so it seems likely that it is indeed called QuickContact in that context.
Looking at the Documentation, I don't see any inherited classes that you could use to do this for something other than contacts.
So, a few starting points, but no solution from me ;-)
This open source project has the same look and feel for the quick actions popup as the twitter app:
http://github.com/ruqqq/WorldHeritageSite/tree/master/src/sg/ruqqq/WHSFinder
It helps to download the whole project because you need a number of drawables, images, and other resources from that project.
The main demo class is called WHSListActivity.java. The other classes you need is QuickActionWindow.java, and QuickActionItem.java.
After that, it's really easy and works great. I use it for my apps.

Categories

Resources