我有一个 spinner
,其模式设置为 dialog
:
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinner1"
android:spinnerMode="dialog"
android:dropDownWidth="match_parent"
android:textAppearance="@style/TextAppearance.Medium"
android:prompt="@string/label_selection" />
如何在其对话框中添加取消按钮?
最佳答案
唯一的方法是创建自己的自定义微调器,例如:
public class MySpinner extends Spinner implements OnClickListener {
//blah-blah
}
需要实现的重要事项:
protected onDraw()
- 它实际上会绘制您的MySpinner
+ 按钮protected void onMeasure(int widthSpec, int heightSpec)
- 定义自定义微调器的大小
Here's a link到涵盖自定义小部件基础知识的教程
关于android - 如何将取消按钮添加到微调对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31024832/