java.lang.Object | |
↳ | android.widget.ListPopupWindow |
A ListPopupWindow anchors itself to a host view and displays a list of choices.
ListPopupWindow contains a number of tricky behaviors surrounding positioning, scrolling parents to fit the dropdown, interacting sanely with the IME if present, and others.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INPUT_METHOD_FROM_FOCUSABLE | Mode for setInputMethodMode(int) : the requirements for the
input method should be based on the focusability of the popup. |
|||||||||
int | INPUT_METHOD_NEEDED | Mode for setInputMethodMode(int) : this popup always needs to
work with an input method, regardless of whether it is focusable. |
|||||||||
int | INPUT_METHOD_NOT_NEEDED | Mode for setInputMethodMode(int) : this popup never needs to
work with an input method, regardless of whether it is focusable. |
|||||||||
int | MATCH_PARENT | Alias for MATCH_PARENT . |
|||||||||
int | POSITION_PROMPT_ABOVE | The provided prompt view should appear above list content. | |||||||||
int | POSITION_PROMPT_BELOW | The provided prompt view should appear below list content. | |||||||||
int | WRAP_CONTENT | Alias for WRAP_CONTENT . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new, empty popup window capable of displaying items from a ListAdapter.
| |||||||||||
Create a new, empty popup window capable of displaying items from a ListAdapter.
| |||||||||||
Create a new, empty popup window capable of displaying items from a ListAdapter.
| |||||||||||
Create a new, empty popup window capable of displaying items from a ListAdapter.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Clear any current list selection.
| |||||||||||
Dismiss the popup window.
| |||||||||||
Returns the view that will be used to anchor this popup.
| |||||||||||
Returns the animation style that will be used when the popup window is
shown or dismissed.
| |||||||||||
Return the current value in
setInputMethodMode(int) . | |||||||||||
Returns the current value in
setSoftInputMode(int) . | |||||||||||
Returns whether the popup window will be modal when shown.
| |||||||||||
Filter key down events.
| |||||||||||
Filter pre-IME key events.
| |||||||||||
Filter key down events.
| |||||||||||
Perform an item click operation on the specified list adapter position.
| |||||||||||
Post a
show() call to the UI thread. | |||||||||||
Sets the adapter that provides the data and the views to represent the data
in this popup window.
| |||||||||||
Sets the popup's anchor view.
| |||||||||||
Set an animation style to use when the popup window is shown or dismissed.
| |||||||||||
Sets a drawable to be the background for the popup window.
| |||||||||||
Sets the width of the popup window by the size of its content.
| |||||||||||
Sets the height of the popup window in pixels.
| |||||||||||
Set the horizontal offset of this popup from its anchor view in pixels.
| |||||||||||
Control how the popup operates with an input method: one of
INPUT_METHOD_FROM_FOCUSABLE , INPUT_METHOD_NEEDED ,
or INPUT_METHOD_NOT_NEEDED . | |||||||||||
Sets a drawable to use as the list item selector.
| |||||||||||
Set whether this window should be modal when shown.
| |||||||||||
Set a listener to receive a callback when the popup is dismissed.
| |||||||||||
Sets a listener to receive events when a list item is clicked.
| |||||||||||
Sets a listener to receive events when a list item is selected.
| |||||||||||
Set where the optional prompt view should appear.
| |||||||||||
Set a view to act as a user prompt for this popup window.
| |||||||||||
Set the selected position of the list.
| |||||||||||
Sets the operating mode for the soft input area.
| |||||||||||
Set the vertical offset of this popup from its anchor view in pixels.
| |||||||||||
Sets the width of the popup window in pixels.
| |||||||||||
Show the popup list.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Mode for setInputMethodMode(int)
: the requirements for the
input method should be based on the focusability of the popup. That is
if it is focusable than it needs to work with the input method, else
it doesn't.
Mode for setInputMethodMode(int)
: this popup always needs to
work with an input method, regardless of whether it is focusable. This
means that it will always be displayed so that the user can also operate
the input method while it is shown.
Mode for setInputMethodMode(int)
: this popup never needs to
work with an input method, regardless of whether it is focusable. This
means that it will always be displayed to use as much space on the
screen as needed, regardless of whether this covers the input method.
Alias for MATCH_PARENT
.
If used to specify a popup width, the popup will match the width of the anchor view.
If used to specify a popup height, the popup will fill available space.
The provided prompt view should appear above list content.
The provided prompt view should appear below list content.
Alias for WRAP_CONTENT
.
If used to specify a popup width, the popup will use the width of its content.
Create a new, empty popup window capable of displaying items from a ListAdapter.
Backgrounds should be set using setBackgroundDrawable(Drawable)
.
context | Context used for contained views. |
---|
Create a new, empty popup window capable of displaying items from a ListAdapter.
Backgrounds should be set using setBackgroundDrawable(Drawable)
.
context | Context used for contained views. |
---|---|
attrs | Attributes from inflating parent views used to style the popup. |
Create a new, empty popup window capable of displaying items from a ListAdapter.
Backgrounds should be set using setBackgroundDrawable(Drawable)
.
context | Context used for contained views. |
---|---|
attrs | Attributes from inflating parent views used to style the popup. |
defStyleAttr | Default style attribute to use for popup content. |
Create a new, empty popup window capable of displaying items from a ListAdapter.
Backgrounds should be set using setBackgroundDrawable(Drawable)
.
context | Context used for contained views. |
---|---|
attrs | Attributes from inflating parent views used to style the popup. |
defStyleAttr | Style attribute to read for default styling of popup content. |
defStyleRes | Style resource ID to use for default styling of popup content. |
Clear any current list selection.
Only valid when isShowing()
== true
.
Returns the view that will be used to anchor this popup.
Returns the animation style that will be used when the popup window is shown or dismissed.
Return the current value in setInputMethodMode(int)
.
ListView
displayed within the popup window.
Only valid when isShowing()
== true
.
INVALID_POSITION
if isShowing()
== false
.Returns the current value in setSoftInputMode(int)
.
true
if this popup is configured to assume the user does not need
to interact with the IME while it is showing, false
otherwise.
Returns whether the popup window will be modal when shown.
true
if the popup window will be modal, false
otherwise.
true
if the popup is currently showing, false
otherwise.
Filter key down events. By forwarding key down events to this function, views using non-modal ListPopupWindow can have it handle key selection of items.
keyCode | keyCode param passed to the host view's onKeyDown |
---|---|
event | event param passed to the host view's onKeyDown |
Filter pre-IME key events. By forwarding onKeyPreIme(int, KeyEvent)
events to this function, views using ListPopupWindow can have it dismiss the popup
when the back key is pressed.
keyCode | keyCode param passed to the host view's onKeyPreIme |
---|---|
event | event param passed to the host view's onKeyPreIme |
Filter key down events. By forwarding key up events to this function, views using non-modal ListPopupWindow can have it handle key selection of items.
keyCode | keyCode param passed to the host view's onKeyUp |
---|---|
event | event param passed to the host view's onKeyUp |
Perform an item click operation on the specified list adapter position.
position | Adapter position for performing the click |
---|
Sets the adapter that provides the data and the views to represent the data in this popup window.
adapter | The adapter to use to create this window's content. |
---|
Sets the popup's anchor view. This popup will always be positioned relative to the anchor view when shown.
anchor | The view to use as an anchor. |
---|
Set an animation style to use when the popup window is shown or dismissed.
animationStyle | Animation style to use. |
---|
Sets a drawable to be the background for the popup window.
d | A drawable to set as the background. |
---|
Sets the width of the popup window by the size of its content. The final width may be larger to accommodate styled window dressing.
width | Desired width of content in pixels. |
---|
Sets the height of the popup window in pixels. Can also be MATCH_PARENT
.
height | Height of the popup window. |
---|
Set the horizontal offset of this popup from its anchor view in pixels.
offset | The horizontal offset of the popup from its anchor. |
---|
Control how the popup operates with an input method: one of
INPUT_METHOD_FROM_FOCUSABLE
, INPUT_METHOD_NEEDED
,
or INPUT_METHOD_NOT_NEEDED
.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to the show()
method.
Sets a drawable to use as the list item selector.
selector | List selector drawable to use in the popup. |
---|
Set whether this window should be modal when shown.
If a popup window is modal, it will receive all touch and key input. If the user touches outside the popup window's content area the popup window will be dismissed.
modal | true if the popup window should be modal, false otherwise.
|
---|
Set a listener to receive a callback when the popup is dismissed.
listener | Listener that will be notified when the popup is dismissed. |
---|
Sets a listener to receive events when a list item is clicked.
clickListener | Listener to register |
---|
Sets a listener to receive events when a list item is selected.
selectedListener | Listener to register. |
---|
Set where the optional prompt view should appear. The default is
POSITION_PROMPT_ABOVE
.
position | A position constant declaring where the prompt should be displayed. |
---|
Set a view to act as a user prompt for this popup window. Where the prompt view will appear
is controlled by setPromptPosition(int)
.
prompt | View to use as an informational prompt. |
---|
Set the selected position of the list.
Only valid when isShowing()
== true
.
position | List position to set as selected. |
---|
Sets the operating mode for the soft input area.
mode | The desired mode, see
softInputMode
for the full list |
---|
Set the vertical offset of this popup from its anchor view in pixels.
offset | The vertical offset of the popup from its anchor. |
---|
Sets the width of the popup window in pixels. Can also be MATCH_PARENT
or WRAP_CONTENT
.
width | Width of the popup window. |
---|
Show the popup list. If the list is already showing, this method will recalculate the popup's size and position.