這裏真的很麻煩。我想從一個片段打開一個對話框片段,但我不能讓它的工作在片段中使用FragmentManager?
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導入,這給我一個紅線錯誤。
而且我不知道如何解決這個...希望你的傢伙的智慧!
喝彩!
你確定這是錯誤嗎?如果這些導入實際上是您在該類文件中的內容,那麼它應該是它上面的行提供了一個錯誤。 –