从另一个片段替换片段

时间:2015-04-15 22:15:35

标签: android facebook android-fragments

我是开发Android的新手。以下教程我在片段中实现了facebook登录。成功时我想要o替换片段并显示一个新片段。我写了这个

            private FacebookCallback<LoginResult> mCallback = new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                AccessToken accessToken = loginResult.getAccessToken();
                Profile profile = Profile.getCurrentProfile();
                ProfileFragment newFragment = new ProfileFragment();
                FragmentTransaction transaction = getFragmentManager().beginTransaction();


                transaction.replace(R.id.container, newFragment);
                transaction.addToBackStack(null);

                transaction.commit();

                /*if(profile!=null){
                    mTextView.setText("Welcome "+ profile.getName());

                }*/

            }

但我无法弄清楚为什么此行transaction.replace(R.id.container, newFragment);在Android Studio中给出了错误:replace (int android.support.v4.app.Fragment) in 'android.support.v4.app.FragmentTransaction' cannot be applied to (int mypackage.ProfileFragment)

0 个答案:

没有答案