gpt4 book ai didi

java - setArguments(bundle) 未定义

转载 作者:行者123 更新时间:2023-12-01 11:53:57 25 4
gpt4 key购买 nike

使用 FragmentPagerAdapter 我试图返回一个 fragment 。但是我最终遇到错误 setArgument(bundle) is undefined 。但我不打算定义它,查看其他示例代码

这是代码

    public static SimpleMapActivity newInstance(int position,String title) {
SimpleMapActivity fragment = new SimpleMapActivity();
Bundle bundle = new Bundle();
bundle.putInt("position", position);
bundle.putString("title", title);
fragment.setArguments(bundle);
return fragment;
}

我创建的PageAdapter是;

        @Override
public Fragment getItem(int position) {

Fragment fragmentByTag = getSupportFragmentManager().findFragmentByTag(makeFragmentName(R.id.pager, position));
System.out.println("*********** fragmentByTag = " + fragmentByTag);
return SimpleMapActivity.newInstance(position, "Fragment with menu");

}

我可以添加更多代码,但我认为这足以解决它,如果您想了解更多内容,请随时询问。提前致谢,亚历杭德罗

最佳答案

SimpleMapActivity 未扩展 Fragment,这就是未定义 setArguments 方法的原因。

关于java - setArguments(bundle) 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28583407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com