【问题标题】:why high API level added method AutoCompleteTextView.setText(CharSequence, boolean) run on low API level device work well为什么高 API 级别添加的方法 AutoCompleteTextView.setText(CharSequence, boolean) 在低 API 级别设备上运行良好
【发布时间】:2015-07-05 20:33:38
【问题描述】:

为什么高 API 级别添加的方法 AutoCompleteTextView.setText(CharSequence, boolean) 在低 API 级别设备上运行良好

doc:https://developer.android.com/reference/android/widget/AutoCompleteTextView.html#setText(java.lang.CharSequence,布尔值)

在文档中说此方法是在 API 级别 17 中添加的 但 我测试过的设备:中兴U880(2.2.2)API8、华为U8860(2.3.6)都运行良好

我想知道为什么?

【问题讨论】:

  • 您可能没有调用该方法,而是在超类中调用了一些重载。发布您的代码。
  • 另一种可能是该方法在 Android 中已经存在了一段时间,但被标记为@hide,因此被排除在 Android SDK 之外。并非 API 级别 17 之前的所有设备都必须具有该方法,因为设备制造商可以更改任何不属于 Android SDK 的内容。

标签: android autocompletetextview android-api-levels


【解决方案1】:

谢谢CommonsWare!

Android 2.2.3 源代码交叉引用:AutoCompleteTextView.java#setText

  /**
967     * Like {@link #setText(CharSequence)}, except that it can disable filtering.
968     *
969     * @param filter If <code>false</code>, no filtering will be performed
970     *        as a result of this call.
971     *
972     * @hide Pending API council approval.
973     */
974    public void setText(CharSequence text, boolean filter) {
975        if (filter) {
976            setText(text);
977        } else {
978            mBlockCompletion = true;
979            setText(text);
980            mBlockCompletion = false;
981        }
982    }

【讨论】:

    猜你喜欢
    • 2015-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    • 2023-03-17
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多