How to create collapse able Menu items in Android? - android

I am designing an Android Application, in which I want to add a filter to filter the choices that are displayed in certain categories, now the thing is I am planning to have show a PopupMenu whenever a user clicks on the filter button, and it is working, but since the number if filers is large. so I want to group them and make them collapse able, and I have seen many apps doing so, but I am not able to implement than in code, if you could provide me with a nice code doing the same, or any tutorial it would be much appreciated. Thank you :)

If you are using json for getting the data, then it will be good to maintain the filter from back end side. So just pass the name of category or categories, for which you want to get filter. and you will get the result from json for all categories. Most of the Apps using this approach. So you can also try this way, to achieve filter.

I'm not sure if i understand your question correctly, but if you want to group some items in your popup ExpandableListView should solve your problem.
Link: http://developer.android.com/reference/android/widget/ExpandableListView.html

Related

Android: ListView Load more (OnScrollListener) Search Filter

I added load-more feature to my app and now I'm wondering, how can I accomplish, that my Search Filter will search also through the items, which are not yet loaded.
Do you have any advice, what is the best way to do it?
Thanks for any answer
I think that depends how you have thought of search functionality. For e.g if you want to make it a local filter then obviously it will filter only loaded items. If search is global then it can always reset current shown list with the filtered items.
In case of global search you can give some visual element to the user where he can switch back to core list.

Android: ListView filtering from a dropdown menu OR checkboxes

I've been browsing these and other "forums" for quite a bit and I've not been able to find a "guide" to this issue I'm facing.
I've had an Android course and I decided to start working on my own app, everything was going smooth until I got to this point: I got a custom listview with several items. Now I want to have either a dropdown menu just above the listview or a few checkboxes so that the user can filter said items according to his selection.
Every tutorial I've read talks about filtering the listview thru an edittext field and the user input, but I want the user to click a button and the filter run.
Has anyone out here got a tutorial/guideline on how can I do this?
Thanks and cheers for your time!
Yours,
/D~
Answering myself as I've managed to do this:
As many internet tutorials show, just make your custom adapter implement Filterable and then create a custom Filter that satisfies your criteria - there's plenty of internet tutorials for this, but I could prolly attach the code if someone needs it.
After that's done, all you need to do is call: adapter.getFilter().filter(yourControlString) from the button/spinner item.
yourControlString will basically tell your custom Filter what do you want to display and what you don't want to - you've to customize that on your CustomFilter. Again, this sounds harder than what it really is.

Component to add arbitrary number of input fields?

I apologize if I'm just missing the obvious. I'm fairly new to Android development, and while I searched for this particular topic, I wasn't exactly sure what to look for (in terms of a "name").
In an application I'm writing, I have a section where the user can enter the names of players. However, this can range anywhere from 1 to whatever, no limit. However, I'm not sure what the best approach for this kind of feature is, or if there's a component that already does something like it.
Basically, the functionality I'm looking for is similar to what you can see in the Edit Contact screen of the phone book; for the phone numbers and email addresses, you can push a little plus button to add a new number/address, or hit the little minus button to remove a number/address.
I can think of several ways to potentially implement this, but in the end I think wrapping it in a custom component would be best (so that you could call "Get Players" and have it return a list of strings by going through each of the inputs and getting the values).
Am I just overthinking this? Is there a component that does that already? Is there some example code that demonstrates a good way to do this?
Thanks!
Could you just use ListView and add a menu with a "Add Players" option? You could customize the list view to have a little checkbox, for example, and then begin the game by pressing the menu ... or add new players dynamically by pressing another menu button.
After playing around with some ideas, I came across a solution that I think will suit what I'm doing. I created a custom component extending LinearLayout. As part of the creation of the component, it creates a row that says "Add new..." with a plus-sign button. Pressing the plus sign button then creates a new row containing an EditText and a minus-button which will remove the row.
I then created a method for this component called getTexts() which returns a List that has all the non-empty Text values from all the components. Testing it in a dummy app, it seemed to work fine.
I think I need to make tweaks to make it more robust (like the ability to add rows programatically, listeners to alert other components when a row is added/removed, and the ability to set the individual EditText values, for instance), but this functions as I imagined.

Extra information within a ListView

I have a list view with some items in it and I would like to know how to add extra information to the side of this? I have a photoshopped example below of what I mean, it's difficult to describe without an image or I would have used google to try and find the answer myself. I want it with the extra text on the right hand side, i've seen it done easily within the iPhone but i'm a bit stuck with android. Thanks.
it's easy in Android too, you need to create a custom layout for a list item and set up an adapter to write to the fields of your new layout. here an example.

Custom options menu in Android

I want to create a custom OptionsMenu in my application. The default OptionsMenu display only three items in one row. Now i want to display five to six items having only icons. Also i want to change the background color of the OptionsMenu but not getting the appropriate way of doing this. If it is possible then please let me know about it.
Short answer
As an user it bothers me when the application changes my android's widgets. I wouldn't recommend changing that and android doesn't provide a way to do it.
Long answer
Even though Android doesn't provide a way to customize that you can always handle the key event and show a view from your own. Similar discussion in stackoverflow.

Categories

Resources