gpt4 book ai didi

android - 创建加号和减号按钮,如日期选择器

转载 作者:行者123 更新时间:2023-11-29 21:45:31 24 4
gpt4 key购买 nike

有没有办法像日期选择器对话框中那样创建加号和减号按钮?我的意思是无需从头开始创建它们。

提前谢谢你。

最佳答案

一种选择是按照 Paresh mayani 的建议去做。

您可以使用可用的 android 资源为您的 Button 设置背景。 Datapicker 使用可用资源 (android.R.drawable) 的向上箭头和向下箭头。您可以使用可用的图像,而不是创建自定义图像并将其设置为按钮的背景。有关您可以使用的所有 android 可绘制对象的列表,请访问以下链接

http://developer.android.com/reference/android/R.drawable.html

以编程方式设置背景

 Button b= (Button) findViewById(R.id.button1);
b.setBackgroundResource(android.R.drawable.arrow_up_float);

在xml中设置背景

    <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:drawable/arrow_up_float"
/>

关于android - 创建加号和减号按钮,如日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15942821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com