How to implement styled popup of AutoCompleteTextView? - android

I need to style a popup window of AutoCompleteTextView. What I noticed on tutorials is that the only styling that people do is setting of custom shape with android:popupBackground attribute. This is not enough for me. I basically need to put custom layout (combination of TextViews, clickable texts and of course array of search result items suggested by AutoCompleteTextView.Here is schematic of my need:
How to implement described? Thanks!

Related

Add separators and icons to android actionbar popup menu

I'm try to customize my app popup menu adding separators and icons.
Basically I would like to obtain a menu like this (from Google Photos app):
How can I achieve this?
Thank you all in advance :)
I dont think there is a straightforward way to add separators and icons to popup menu.
I suppose, you have to use PopupWindow. Using PopupWindow, you have to design the layout. So you can design it the way you want, like having icons and separators. But the catch here is, you have to position the PopupWindow using x,y and gravity parameters, and also the fade-in animation.
https://developer.android.com/reference/android/widget/PopupWindow.html
you can use multiple row in listview to obtain the design,
look at this example: http://www.survivingwithandroid.com/2014/08/android-listview-with-multiple-row.html

Spinner Dropdown instead of Pop up with an overlay?

I would like to have my spinner drop down just like a web form. I don't want the options to pop up in a modal style window. Is this possible, and if so, how?
The feature you're looking for is the spinnerMode attribute which has "popup" and "dropdown" modes, which you should set to "dropdown" in order to get what you want. Just add
android:spinnerMode="dropdown"
to the declaration in your layout XML.
Looks like you could just use MODE_DROPDOWN with the spinner.
This is not supported in SDK as far as I know, so I guess you will have to write your own Spinner to get this functionality. It would be nice though :)

Help styling a view at runtime.

I've jumped around looking for a proper solution to this problem, but can't find one. The answer might be that it's impossible, but I'm going to try one more time, even though many similar questions have been asked.
I have a view (it happens to be a RatingBar, but it could be a button or a TextView or even an ImageView) that I want a custom style for. Depending on something, I want it to (for example) use Red Stars, or Blue Stars, or Orange Stars. I want to use this view in a list, with a custom list adapter, so that based on some attribute in the underlying list data, the item list view shows either the Red-Star RatingBar, or the Blue-Star RatingBar, or the OrangeStar RatingBar.
I've attempted building a style from code (choosing the right drawables that reflect the color stars I want), and then having the custom ListAdapter create a new RatingBar with the appropriate style (since a view's style can't be changed after the view is created), but when I do that the RatingBar never shows up. I'm not sure if this is expected, or if I have something else wrong.
It's like I want a selector for my image selector, or maybe another (custom?) attribute for the selector I already have.
If I create a CustomView, that extends RatingBar, that has an extra attribute, would an xml-defined Selector be able to access that attribute and use it to select a different image?
I'd like to figure this out, because the only alternative I can come up with is to not use a ListView with a ListAdapter, which basically results in me writing more custom code.
Thoughts?
Have you tried using themes? You can define a theme for the RatingBar in styles.xml. Within this RatingBar theme you can define a android:progressDrawable, which will refer to a drawable. Create multiple themes, that each point to a different drawable. Having these different themes, you will be able to programmatically set the RatingBar Widget android:style attribute to support these themes (red, blue, green) that you create.

Do Android controls/widgets have choice of styles?

I have a column of Checkboxes and associated EditTexts and I want one pair of these to have a distinct appearance because it has a distinct significance.
Short of writing custom controls, or using custom drawables, does Android have any way to style or alter the appearance of basic controls like buttons, checkboxes, etc, in the XML where the control is declared? Or is there just one native style or appearance for all Android Checkboxes, Buttons, EditTexts, etc?
Thanks in advance.
You can almost custom everything related to style:
http://developer.android.com/guide/topics/ui/themes.html
In fact, an Android Button is just a TextView with different style. In source code, the Button is just an extend to TextView with no overriding.

style a ListView as a standard ContextMenu

I am wondering where the default ContextMenu style is defined... to copy/use it!
I have few ListView in my app, using the provided TexView layout android.R.layout.simple_list_item_1. My listings are looking odd (black background) compare to the default ones like the ContextMenu (white background).
So if you know where it is, or how to make my ListView having a "standard" style, I would be glad to know about it ;)
Thanks
jo
I think the Context Menus look identical to the regular Options Menu. And those menu items are setup with a layout found at:
$(SDK_ROOT)/platforms/android-$(API_LEVEL)/data/res/layout/menu_item.xml.

Categories

Resources