的setEnabled()与setClickable(),有什么区别? [英] setEnabled() vs setClickable(), what is the difference?

查看:2388
本文介绍了的setEnabled()与setClickable(),有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到现在,当我想停止从$ P $用户pssing的按钮,我将设置 button.setClickable(假); ,通常将文本更改为某种灰色的(让用户知道该按钮被禁用)。今天,我偶然发现了的setEnabled()属性。

所以我去的文件,看看下面的方法的解释:

 的setEnabled(启用布尔)
   设置此观点的启用状态。
 

这是什么意思,甚至?之间能状态/可点击状态,并禁用状态/不可点击状态的区别是什么?可能有人请解释什么是做什么我做previously,使用可点击的属性,并使用的setEnabled()属性之间的区别?什么时候应该使用?我搜索的StackOverflow,但没有找到任何有关。先谢谢了。

解决方案
  

这到底是什么意思?

引述的维基百科页面的GUI窗口小部件

  

在一个应用程序的上下文中,一个小窗口可被启用或在给定时间点被禁用。启用的窗口小部件有事件,如键盘或鼠标操作作出反应的能力。不能对这类事件响应小组件被视为无效。禁用窗口小部件的外观通常是从启用的部件不同;残疾人小窗口可在较淡的颜色得出,或者可以在视觉上遮蔽以某种方式。查看图像的例子的权利。

这个概念已经存在了几十年,并在大多数GUI框架中找到。

  

什么是能状态/可点击状态,并禁用状态/不可点击状态之间的区别是什么?

在Android上,一个小部件,不点击不响应点击事件。禁用的小工具,不仅无法点击,但同时也直观地表明,它是禁用的。

  

你是什么意思??..since它使按钮在视觉上已禁用,它是如何改变它在视觉上

是什么让一个按钮的外观和反应与按钮是它的背景,这是一个 StateListDrawable 。有用于禁用状态特定的图像。

Until now, when I wanted to stop the user from pressing the button, I would set the button.setClickable(false); and usually change the text to some kind of grey colour (to let the user know that the button is disabled). Today I stumbled upon the setEnabled() property.

So I went to the documentation to see the method's explanation below:

setEnabled(boolean enabled)
   Set the enabled state of this view.

What does this even mean? What is the difference between enable state/clickable state and disabled state/not clickable state? Could someone please explain what is the difference between doing what I was doing previously, using the clickable property and using the setEnabled() property? What should be used when? I searched StackOverflow but could not find anything related. Thanks in advance.

解决方案

What the hell is that mean?

Quoting the Wikipedia page for "GUI widget":

In the context of an application, a widget may be enabled or disabled at a given point in time. An enabled widget has the capacity to respond to events, such as keystrokes or mouse actions. A widget that cannot respond to such events is considered disabled. The appearance of disabled widget is typically different from an enabled widget; the disabled widget may be drawn in a lighter color, or may be visually obscured in some way. See the image to the right for an example.

This concept has been around for a couple of decades and can be found in most GUI frameworks.

what is the difference between enable state/clickable state and disabled state/ not clickable state?

In Android, a widget that is not clickable will not respond to click events. A disabled widget not only is not clickable, but it also visually indicates that it is disabled.

what do you mean by: "..since it makes the Button visually "disabled"? how does it changes it visually?

What makes a Button look and respond like a Button is its background, which is a StateListDrawable. There is a specific image used for the disabled state.

这篇关于的setEnabled()与setClickable(),有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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