import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
public class FragmentDiscover extends Fragment
{
private View rootView;
private ImageButton folderButton;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Inflate the layout for this fragment
rootView = inflater.inflate(R.layout.activity_9a_discover , container, false);
bindActivity();
return rootView;
}
private void bindActivity()
{
cardStack = (SwipeDeck) rootView.findViewById(R.id.main_frag_swipe_deck);
dragCheckbox = (CheckBox) rootView.findViewById(R.id.main_frag_checkbox_drag);
dragCheckbox.setVisibility(View.GONE);
//Folder button
final android.app.FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager1 = getFragmentManager();//RED LINE ERROR?!?!?
final FoldersDialogFragment foldersDialogFragment = new FoldersDialogFragment();
folderButton = (ImageButton) rootView.findViewById(R.id.main_button_folders);
folderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
foldersDialogFragment.show(fragmentManager, "folderPop");
}
});
makeSomeSampleCards();
}
使用FragmentManager fragmentManager1 = getFragmentManager();
第foldersDialogFragment.show(fragmentManager, "folderPop");
行成为红线错误。
使用FragmentManager fragmentManager1 = getSupportFragmentManager;
使用v4导入,这给我一个红线错误。
我不知道如何解决这个问题......希望你的家伙有智慧!
喝彩!
答案 0 :(得分:1)
你能展示FoldersDialogFragment的代码吗?
我怀疑当你的片段继承自support.v4.app.Fragment
时,你的对话框片段没有。
答案 1 :(得分:1)
当您在Fragment
范围内时,使用getChildFragmentManager()检索android.support.v4.app.FragmentManager
以添加子片段(其他片段拥有的片段)。
当然,您还应该确保使用android.support.v4.DialogFragment作为FoldersDialogFragment
的基类。