问题
I have a ListView
which handles onClick events by showing a PopUpMenu
. However, I want the user to see the little triangle inside the views that can be clicked.
I tried using a Spinner
, because that element looks like what I'm after, but I can't set the title of the Spinner
to anything other than its options.
Of course I could custom make everything but as this is not a new pattern I thought maybe there's already something out there. I just can't find it myself.
Example of what I'm after:

回答1:
Perhaps you are looking for the prompt attribute that you can set for a spinner?
Beyond that, I would suggest using the SlideExpandableListView if you haven't already invested too much time in your current implementation and if that is the pattern that you would like to achieve:
This library allows you to have custom listview in which each list item has an area that will slide-out once the users clicks on a certain button.
回答2:
If you use ActionBarSherlock
, you can use the triangle ABS uses:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
etc />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:contentDescription="@string/expand_triangle"
android:src="@drawable/abs__spinner_ab_default_holo_light" />
</RelativeLayout>
来源:https://stackoverflow.com/questions/14306923/show-triangle-inside-the-view-that-opens-a-popupmenu-like-with-a-spinner