gpt4 book ai didi

java - 无法解析方法 getChildFragmentManager()

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:39 25 4
gpt4 key购买 nike

错误:仅当 getChildFragmentManager() 方法在 android.support.v4.app.Fragment 中可用时才能使用“childFragmentManager”参数,请更新您的支持库版本。

我已经在我的 gradle 中编译了“com.android.support:support-v4:24.2.0”。我的代码如下;

 import android.support.v4.app.Fragment;
import org.androidannotations.annotations.*;
import org.androidannotations.annotations.sharedpreferences.Pref;
.
.

@EFragment(R.layout.fragment_main)
public class MainFragment extends Fragment {
@Pref
ApplicationSettings_ applicationSettings;
@ViewById(R.id.bot)
public LinearLayout bot;
@ViewById(R.id.center)
public LinearLayout center;
@Bean
UIItemGenerator uiItemGenerator;
@SystemService
LayoutInflater layoutInflater;
@FragmentById(value = R.id.contentFragment,childFragment = true)
public ContentFragment contentFragment;

public MainFragment() {
}

@Click(R.id.imagebutton_ribbon)
public void ribbonClick(View view) {
view.setVisibility(View.GONE);
}

.
.
.
@AfterViews
public void afterViews() {
if (contentFragment == null)
contentFragment = (ContentFragment) this.getChildFragmentManager().findFragmentById(R.id.contentFragment);
for (int j = 0; j < bot.getChildCount(); j++) {
bot.getChildAt(j).setSelected(false);
}
for (int j = 0; j < top.getChildCount(); j++) {
top.getChildAt(j).setSelected(false);
}
ll_home.setSelected(true);
ll_allrooms.setSelected(true);
initUI();
contentFragment.generateContent(-1, -1);
imagebutton_top_rightarrow.setSelected(true);
imagebutton_bot_rightarrow.setSelected(true);

最佳答案

getChildFragmentManager() 是 Fragment 上的一个方法并检查您的导入语句

import android.support.v4.app.FragmentManager;

我认为你正在使用AppCompatActivity(FragmentActivity的子类),你必须使用这个

getSupportFragmentManager()

关于java - 无法解析方法 getChildFragmentManager(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40521789/

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