错误:仅当android.support.v4.app.Fragment中有getChildFragmentManager()方法可用时,才可以使用'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语句
import android.support.v4.app.FragmentManager;
我认为您正在使用AppCompatActivity(FragmentActivity的子类),您必须使用此
getSupportFragmentManager()
关于java - 无法解析方法getChildFragmentManager(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40521789/