Android 其他碎片没有显示出来
我一直在搜索显示Android 其他碎片没有显示出来,android,android-fragments,Android,Android Fragments,我一直在搜索显示片段,但问题仍然存在,我无法让它工作 我的问题是,当我在菜单中添加repeat\u entry以显示另一个片段时,该片段不会显示,但当我单击action\u settings时,该片段会显示 @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will //
片段
,但问题仍然存在,我无法让它工作
我的问题是,当我在菜单中添加repeat\u entry
以显示另一个片段时,该片段不会显示,但当我单击action\u settings
时,该片段会显示
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out);
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
selectTabToShow(String.valueOf(R.id.action_search));
CategorySettings fragemnt = (CategorySettings) getFragmentManager().findFragmentById(R.id.categorySettings);
fragemnt.refresCategoryList();
Fragment fragment = new CategorySettings();
ft.add(R.id.category_cont,fragment,"asdf");
ft.commit();
return true;
}else if(id == R.id.repeat_entry){
Toast.makeText(MainActivity.this,"ssdf sdf",Toast.LENGTH_SHORT).show();
Fragment fragment = new RepeatEntry();
ft.add(R.id.category_cont,fragment,"repeat tag");
ft.commit();
Toast.makeText(MainActivity.this,"ssdf sdf",Toast.LENGTH_SHORT).show();
return true;
}
return super.onOptionsItemSelected(item);
}
到现在为止,这是我的RepeatEntry片段
public class RepeatEntry extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState){
View v = inflater.inflate(R.layout.repeat_entry,container,false);
return v;
}
}
伙计们,请帮帮我,我是新来的。尝试替换
ft.replace(R.id.category_cont,fragment,"repeat tag");
请发布RepeatEntry()的代码;fragment.@jameshwart,尝试使用getFragmentManager()@Anand Raj getChildFragmentManager()的getChildFragmentManager()intead先生,我收到无法解析方法sirhi的错误谢谢您的回答,但它不起作用先生:(