Returns whether the preference needs to display a soft input method when the dialog is displayed. Default is false. Subclasses should override this method if they need the soft input method brought up automatically.
但是,它具有 @hide
标记,并且在 SDK 中不可见。尽管如此,DialogPreference
的子类仍然实现它:
- EditTextPreference.java (其中还有
@hide
)
我的问题:
- 为什么会有
@hide
? - 如果我扩展
DialogPreference
并希望显示软键盘,我应该实现它吗?
最佳答案
根据一般经验,不应实现隐藏的 API。 原因可能是 API 正在开发中并且可能会更改、API 仅供内部使用、不稳定等...
在本例中,您认为 EditTextPreference.java 类直接调用此方法是正确的,但您不应该得出这样的结论:这意味着其他子类应该执行相同的操作。
事实上,如果您检查将此方法添加到类中的开发人员的提交消息,您会看到:
changeset: 1d458570757e607f0dc11fb0e963017916ac0701
summary: Show keyboard automatically in EditTextPreferences dialogs
User: ...
Date: Tue Sep 15 19:25:51 CEST2009
因此,此方法似乎旨在由 EditTextPreferences 使用,而不是由其他人使用。
关于java - 为什么 DialogPreference.needInputMethod() 被隐藏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38737363/