I want to add a spinner in my app like the below image. Actually this drop down spinner should contain contents which can be selectable and also section headers which cannot be clickable. Some advise to use section in listview, others expandable view.
But nothing helps .. Please some on help me to complete this.
Check this https://code.google.com/p/android-section-list/ this can be helpful..
You'll need to set a Custom dropdown resource to the Adapter which is set to the Spinner and also you'll need to have a custom Adapter which will setEnabled() certain items like "View As" and "Sort By" to false.
EDIT:- it's isEnabled() and not setEnabled().. my bad!
Related
Could someone please help point out the difference between the the two parameters that I highlighted. Aren't they the same thing, the layout resources used to create each view (or item) in the dropdown list? What does the ArrayAdapter.setDropDownViewResource() do exactly?. Thank you very much for your time. Any help is greatly appreciated.
When you are using Spinner or AutocompleteTextView you use setDropDownViewResource to identify which layout should be used to create drop down list items view.
But the first parameter identifies the layout that should be used to create view for selected item from drop down list.
Note: As I experienced, the last point is correct in Spinner, not in AutoCompleteTextView. Because AutoCompleteTextView is an EditText itself.
You can read more about Spinner and AutoCompleteTextView
I'd like to show a menu when I click in a view (Linear/RelativeLayout) like the images below
Anybody knows how to do it?
Thanks!
The UI-Element you're looking for is called a Spinner (Docs). As far as I know the default implementation of the Spinner/Dropdown-List displays only text without any kind of drawable (circle) like in your screenshot.
So what you have to do is to create you own layout and Adapter for the Spinner.
The view you are looking for is called Spinner. Android has excellent documentation about this subject.
If you want the spinner to go up, like in your picture, you will have to place it at the bottom of your view, since it will only go up if there is no room below
You should use the Spinner view
If you would like to customize the view elements, than you should change the default ArrayAdapter to yours and override the getView() method.
i have list view with checkbox and if I select some item than every 9 item is selected too.
I am using onClickListener on checkbox.
Do you know how solve the situation? One item checked, but more selected.
If you wanna see my source code, just let me know and I will put there.
Thanks for help
Lukas P.
Your problem comes from views being recycled by Android. You need to store the check box state of each row in some container (eg. a list) and then explicitly set the checked state to the correct state in getView.
See this similar question:
custom ListView with checkboxes checking unchecked items
I am trying to implement a dropdown list that looks like the web drop down list.. But what i could implement was only the spinner which can select an item but it doesn't give the idea of drop down..anyone who knows a work around it?..
Thanks in advance.
Web like drop down means, do you think about like lable on top "Select Value" and below a list of values ?
If yes then you can do it by creating a custom Spinner. Just create a lable, on click of it open a Dialog and bind list values to the dialog. So it will behave completely same as Spinner.
Hope it helps
Create a dummy button similar like dropdown. Just below it use invisible/gone scrollview. Inside scrollview use listview. On click, make it visible.
First, I want to imitate the effect like "android.R.layout.simple_spinner_dropdown_item"
which is TextView+radiobutton
but either the getView() or getDropDownView only cares about one row at a time, while the whole radiobuttons in spinner is like one RadioGroup, and when dropdown view is opened, the radiobutton with which item is selected before must be checked.
so how can I imitate the layout like simple_spinner_dropdown_item?
Second, I want to add different ImageView in each row, so I can't just use the default simple_spinner_dropdown_item, I must redefine the ArrayAdapter.
So, is there a best way to get through these?
I like the layout in simple_spinner_dropdown_item, but I also want to add ImageView...
Please give me any clue at all
Thanks!!
extend the adapter. Override getView() and change the view that is returned to what you are after.
Cheers,
if you want to implement a more generic adapter without overriding the arrayadapter you can look at the post at http://blog.app-solut.com/2011/03/using-custom-layouts-for-spinner-or-listview-entries-in-android/ its using the baseadapter which can be modified as desired.