安卓:绘制一个按钮作为微调 [英] Android: Drawing a button as a spinner

查看:84
本文介绍了安卓:绘制一个按钮作为微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展按钮,并作为一个多层次的微调定制的Andr​​oid视图 - 当它是pressed它显示了一系列的微调式的对话框,允许用户优化他们的选择。在这种情况下,它允许用户选择该天,然后小时,然后分钟(在5分钟的间隔),他们希望的拾取器发生。当对话框不活跃,当前选择的文本描述显示的按钮。

I have a custom android view that extends 'Button' and acts as a multi-level spinner - when it is pressed it displays a series of spinner-like dialogs that allow a user to refine their selection. In this case, it allows the user to select the day, then hour, then minute (in 5 min intervals) that they want a pickup to occur. When the dialog is not active, a text description of the current selection is shown on the button.

我想直观地表明,用户可以通过$ P $更改选择pssing按钮,并认为一个微调的外观正是我需要它。我想要的效果是相同的设备上的其他纺纱,并能够很容易地改变按钮上的文字,但我不知道如何实现,没有它是缺憾。我应该如何去显示一个按钮,一个微调般的图标与设备?

I want to visually indicate that the user can change the selection by pressing the button, and think that the look of a spinner is exactly what I need for it. I want the look to be the same as other spinners on the device, and be able to easily change the text on the button, but I'm not sure how to achieve that without it being kludgy. How should I go about displaying a button as a spinner-like icon that is consistent with other spinners on the device?

推荐答案

我找到了解决我的问题。在构造函数中为我的扣我设置的背景绘制资源是btn_dropdown。

I found a solution to my question. In the constructor for my button I set the background drawable resource to be "btn_dropdown".

public DateAndTimePicker(Context context) {
    super(context);
    this.setBackgroundResource(android.R.drawable.btn_dropdown);
}

看起来一样的微调按钮,没有任何按键的行为发生了变化,并且按钮上的文字中心正常。

It looks the same as the spinner buttons, none of the button behavior has changed, and the button text centers correctly.

这篇关于安卓:绘制一个按钮作为微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆