我有自定义ArrayAdapter和自定义项目布局Spinner。<?xml version="1.0" encoding="utf-8"?><RelativeLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:clickable="true"    android:layout_height="wrap_content">    <TextView        android:id="@android:id/text1"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:minHeight="48dp"        android:layout_toStartOf="@id/delete"        android:drawablePadding="8dp"        android:gravity="center_vertical|start"        android:paddingTop="8dp"        android:paddingBottom="8dp"        android:paddingStart="16dp"        android:ellipsize="none"        android:textAppearance="@style/TextAppearance.AppCompat.Menu" />    <ImageButton        android:id="@+id/delete"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:padding="16dp"        android:layout_alignParentEnd="true"        android:layout_centerInParent="true"        android:contentDescription="@null"        android:background="?attr/transparentRoundRipple"        android:src="@drawable/ic_delete_grey600_24px" /></RelativeLayout>在这个布局中有一个按钮可以删除这个项目@Overridepublic View getDropDownView(int position, View view, ViewGroup parent){    if (view == null) {        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);        view = inflater.inflate(R.layout.spinner_user_agent_item, parent, false);    }    TextView textView = view.findViewById(android.R.id.text1);    textView.setText(getItem(position));    ImageButton deleteButton = view.findViewById(R.id.delete);    deleteButton.setOnClickListener((View v) -> removeAgent(getItem(position)));    return view;}但问题是这个按钮的监听器阻止了元素本身的点击,我无法从列表中选择它。是否可以更改行为并使其可以单击按钮(用于删除)和元素本身(用于选择)?
                    
                    
                添加回答
举报
0/150
	提交
		取消
	
 
                    