如何使整行微调器下拉选项可单击

时间:2014-08-29 09:57:19

标签: android

我希望整行的微调器选项都是可点击的。我谷歌和尝试不同的选项,但只有TextView仍然可点击。

enter image description here

Spinner item xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:descendantFocusability="blocksDescendants"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tvSpinerItemDescription"
        android:layout_width="fill_parent"
        android:layout_height="48dp"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:fontFamily="sans-serif-light"
        android:gravity="center"
        android:paddingLeft="10dp"
        android:textColor="@color/dark_gray_4"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/tvSpinerItemID"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:visibility="gone" />

</LinearLayout>

2 个答案:

答案 0 :(得分:0)

<Spinner 
android:id="@+id/my_spinner"
...
android:spinnerMode="dropdown"/>



ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);

答案 1 :(得分:0)

试试这个

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical" >

<TextView
    android:id="@+id/tvSpinerItemDescription"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:fontFamily="sans-serif-light"
    android:gravity="center"
    android:paddingLeft="10dp"
    android:textColor="@color/dark_gray_4"
    android:textSize="16sp" />

<TextView
    android:id="@+id/tvSpinerItemID"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:visibility="gone" />