繁体   English   中英

如何将取消按钮添加到微调对话框?

[英]How to add cancel button to spinner dialog?

我有一个模式设置为dialogspinner

        <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
}

需要执行的重要事项:

  1. protected onDraw() - 它实际上会绘制你的MySpinner + 按钮
  2. protected void onMeasure(int widthSpec, int heightSpec) - 定义自定义微调器的大小

这是教程的链接,其中涵盖了自定义小部件的基础知识

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM