Show triangle inside the view that opens a popupme

2019-07-11 19:59发布

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:

spinner example

2条回答
女痞
2楼-- · 2019-07-11 20:39

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.

查看更多
神经病院院长
3楼-- · 2019-07-11 20:41

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>
查看更多
登录 后发表回答