Android的AutoCompleteTextView在API17高版本添加的setText函数在低版本系统居然能正常调用?官方文档是不是不靠谱了?

官方文档:https://developer.android.com/reference/android/widget/AutoCompleteTextView.html#setText(java.lang.CharSequence, boolean)

 

public void setText (CharSequence text, boolean filter)

Added in API level 17

Like setText(CharSequence), except that it can disable filtering.

Parameters
filter If false, no filtering will be performed as a result of this call.

//官方文档标注为API.17才添加:public void setText(CharSequence text, boolean filter)
//Android Lint 是会检测到错误的!
//但是经过实际的机器测试中兴U880的2.2系统API8居然运行一切正常!很奇葩!
//为了以防万一,还是做一下异常处理

try
{
this.mCuurentView.setText(“something”, false);
}
catch (final Exception ex)
{
LogEx.e("setText(CharSequence text, boolean filter)果然报错了!", ex);

}

 

 

android - why high API level added method AutoCompleteTextView.setText(CharSequence, boolean) run on low API level device work well - Stack Overflow
http://stackoverflow.com/questions/29894904/why-high-api-level-added-method-autocompletetextview-settextcharsequence-boole/29958789#29958789

 

Another possibility is that the method had been in Android for some time, but was marked with @hide and therefore was excluded from the Android SDK. Not every device before API Level 17 will necessarily have that method, as device manufacturers can change anything that is not part of the Android SDK. –  CommonsWare2 days ago

Thanks CommonsWare!

Android 2.2.3 Source Code Cross Reference: 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    }

 

posted @ 2015-04-27 19:39  Asion Tang  阅读(659)  评论(0编辑  收藏  举报