【发布时间】:2017-08-10 22:11:02
【问题描述】:
我正在使用 viewpager 并编译 API 23。我在我的代码中显示以下语句的编译错误,但该项目确实编译。
List<Fragment> fragments = getSupportFragmentManager().getFragments();
此外,我在支持片段管理器和不支持片段管理器的 android 文档中都找不到此方法。有谁知道这里发生了什么?
【问题讨论】:
-
对迈克尔的回答的第一条评论说明了一切......stackoverflow.com/questions/6102007/…
We shouldn't use this method. It is marked with @hide and was not supposed to be included with the support library jar. It should not be considered part of the exported API.由于它被隐藏,我猜Google最终决定删除该方法。 -
你使用了 import android.support.v4.app.Fragment; 吗?
-
从支持库的 24.1.1 版开始,该方法尚未被弃用。究竟显示的错误是什么?
-
@Tanis.7x 无法解析方法。 (基本上只是在方法下加了一个红色下划线,但是项目编译好了。
-
@sonnv1368,是的,我做到了。