我可以做一个按钮会被禁用,仍然听的点击? [英] Can I make a button appear disabled and still listen for clicks?

查看:108
本文介绍了我可以做一个按钮会被禁用,仍然听的点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想变成灰色按钮,使其显示被禁用的用户,但还是听的点击,这样我可以显示一个信息,就是解释了为什么按钮是不适用的用户。

I'd like to gray out a button so it appears disabled to the user, but still listen for clicks so that I can display a message to the user that explains why the button isn't applicable.

我想,以确保Android的API是一个配置无论是适当的标准禁用的外观,而不是手动设置按钮的颜色以灰色,等什么是做到这一点的最好方法是什么?

I'd like to ensure that the Android API is the one configuring whatever is the appropriate standard disabled appearance as opposed to manually setting the button color to gray, etc. What's the best way to do this?

相关报道: Android的 - 听禁用的按钮

推荐答案

您也可以手动设置按钮的背景下,以默认的为残疾。但离开启用按钮,并以正常方式处理click事件

You could also manually set the background of your Button to the default one for disabled. But leave the button enabled and handle the click events in the normal fashion

这样的事情应该这样做:

something like this should do it:

mBtn.setBackgroundResource(android.R.drawable.btn_default_normal_disabled);

这篇关于我可以做一个按钮会被禁用,仍然听的点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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