Android Search View Filter - android

I have an Android app with a Main Menu filled with buttons. In the Action bar corresponding to this view I have a Search Button configured to use with the Search View widget.
For this to work I have another class that is the searchable one that makes the hard work and has a List View with all the products that my database has.
What I'd like to do, and I don't know how, is that when the user is in the Main Menu and presses the search button, nothing changes until it introduces some letter. When he does, it should start show the filtered products list, just like WhatsApp app does with the contacts and conversations. This should be done "on top" of the buttons that my Main Menu already has, because if I change to another Activity then the Search view widget will close.
What am I thinking wrong here?

Check this code out:
https://github.com/commonsguy/cw-omnibus/tree/master/ActionBar/SearchView
If I understand you, this is what you do currently:
https://github.com/commonsguy/cw-omnibus/tree/master/Search/Lorem
He does "Query-style search" but you can also do "Filter-style search" mentioned at page 2521 in the book from Marc Murphy. But this is not described. So far I'm using the first github example.
This is also a nice example that expand on Lorem with automatic suggestions. Only work for Activity and not Fragment (also found in SDK samples/android-14):
https://github.com/android/platform_development/tree/master/samples/SearchableDictionary

Related

Architecture of activity / fragments for search bar

I have a project in which on main screen I show a list of items . (An activity and a fragment that contains the list )
In title bar I want to add a search functionality with autocompletetextview .
Now in title bar there are the title and "search" button . When the search will be clicked the title will be gone and autocomplete visible .
I would like to follow the functionality that is now in common apps : messages , gmail etc but I can t figure what it is the best solution regarding architecture of fragments/activity components to implement .
1, When I clicks the search button to show another fragment ?
2. When I click search button , title change visibility to gone and it will be used the same fragment with items and it will be updated ?
try with a simple MVP, organizing the view in a passive view(less data as possible). I have the feeling you are not practical of architecture if you ask, because looks as a simple question. MVP is in my personal opinion the best way to start.
you can test your app View using Espresso, and the business logic into the presenter with Junit.
From the project indicated on the first link, you can easy clone the project and see an App that is quite similar to the one you use( on click opens a new activity, activities/fragment) plus much more.

Android TalkBack keep highlighted position on Screen Rotation

Use case:
Enable the Google TalkBack accessibility service and navigate to an
app (e.g. Google Messenger)
In this app, assuming that you'll be presented with a list of items
to select, arbitrarily navigate to one of them using Talkback gestures (swipe right or just click once on one of them)
Rotate the screen
Expected behaviour:
The previously highlighted item should still be highlighted; the user
should be able to continue it's navigation
The Google Messenger app is a perfect example of this correct
behaviour
Messenger After rotation
My Sunshine app behaviour:
The previously highlighted item is not highlighted after Screen
Rotation
The user has to navigate again to the previously selected item
Depending on the screen, finding and having an item selected again can be a pain... not what we want to induce to our user
Sunshine After rotation
How should we implement this?
I'm thinking, as a solution, at Accessibility Events and intercepting them... but this doesn't seem to be right, doesn't seem to be "best practice" (e.g. creating a Custom View and implement the methods handling these Events)
! Note that the green highlighted list item doesn't seem to be focused (getCurrentFocused() returns null)
! Note that the list items become focused if we use D-Pad navigation, instead of TalkBack navigation (but this is another discussion...)
L.E:
I've spend a whole day on this, trying to "get the focus" of the
highlighted item, but the item is NOT focused. This is why I assume
that this feature must be tackled in some other way and I would like
to know your (!) experienced opinion before I spend another 2 days
re-creating all the used Android components (as I assume it could be done - this doesn't sound very "best practice", doesn't it ?)
This is NOT a homework, there's nothing wrong with my current code
(so, there's no code to post, unless one would like my whole project)
and, given that this is my first post, I could not attach more than 2
pictures (this is why the "before" screens are missing)
Just give me a good hint, based on experience, and I will implement it and post the finished, working code here.
It should work out of the box if you implement stable IDs in your RecyclerView.Adapter (and potentially disable the ItemAnimator on the RecyclerView (rv.setItemAnimator(null)) which you can do conditionally if TalkBack is enabled).
Here's a blog post I wrote about the item animator bug.
I ran into the same problem while working on the same project.
Hint: listView.setItemChecked(int position, boolean value);
Good luck :)

How to design an android activity in order to view recent posts with the support of "see more" property like facebook?

I want to develop an android application in order to facilitate the communication between students in some college through sharing posts and subjects written by them, so my idea is to create an activity showing recent posts.
i think that i need listview widget to show posts in a way such that each item in this listview will show one post with its title. is that correct? please, i want just the names of widgets which may used in such activity, and how to support "see more" for each post like facebook?
thanks
For see more you can use Floating action button. If new posts are available and the use scrolls down then the floating action button become visible.

android 4.0 spinner usage

I want to be able to do what is on the picture, provided by this link, under the "Allow cutting through hierarchies" section. I thought that I could do that using a spinner, but from the android documentation I realized that a spinner can show one child at a time and lets the user pick among them. In my case, (and from the example I provided), you have some other text displayed, and then you can choose from some other options provided in sth that looks like a popup, list that contains the things that i want to choose from. I don't know how this is implemented, but it's used in the google music app for android 4.0. If someone has an idea, have implemented sth like this, please give me some advice.
It is not a spinner. Its just a view (in the Mail app a relative layout) See here
On click this View opens a popupmenu.
Therefore it is looking like a spinner but you can add you custom behaviour.

Android app, showing a keyboard

I recently wrote my first app for android, and I created a listview for selecting an element from a list of about 500 items. Since it's basically the default listview, it's searchable, and I can bring up the onscreen keyboard by holding down the menu button, but I was wondering if there was a way to bring up the keyboard automatically (and not make it freak out if the phone has a physical keyboard). Does anyone know how I can do this? I've been searching around and haven't found anything.
Add this to your xml activity list definition (AndroidManifest.xml)
android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
Maybe not exactly what you want, nevertheless; you could add a EditText above your list. When this EditText gets focus (which it will by default when you show your activity, presuming it's the first GUI component on the layout) it will also automatically trigger the software keyboard.
The neat thing of this approach is that it gets even more intuitive for the user that he or she can actually search the list by entering a search criteria.

Categories

Resources