2017-03-17 5 views
2

を退けた後、それはユーザーがボタンをクリックしたときに、それはDevRegistrationを呼び出します、プロフィール断片で今リロードフラグメントDialogFragmentは、ユーザーがプロファイルを選択したとき、私は、活動としてIndex.classを持って

if (id == R.id.nav_profile){ 
     FragmentTransaction transaction = getSupportFragmentManager() 
       .beginTransaction(); 
     transaction.setCustomAnimations(R.anim.enter,R.anim.exit,R.anim.enter,R.anim.exit); 
     transaction.replace(R.id.flContent, new Profile(), "ProfileFragment"); 
     transaction.addToBackStack(null); 
     viewPager.getAdapter().notifyDataSetChanged(); 
     transaction.commit(); 
    } 

フラグメントプロファイルを呼び出しますアクティビティ

case 1: 
      btnBeDeveloper.setText("Developer Console"); 
      btnBeDeveloper.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        Intent index = new Intent(getActivity(), DevRegistration.class); 
        startActivity(index); 
       } 
      }); 
      break; 

DevRegistrationクラスでは、登録ボタンをクリックすると、ダイアログフラグメントクラスが表示されます。 ダイアログ・フラグメント内のボタンをクリックすると、どのようにプロファイル・フラグメントをリフレッシュできますか?

ダイアログ断片クラス:ところで

public class df_SuccessDevRegistration extends DialogFragment { 

Button btnDevGoProfile; 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
    View rootView = inflater.inflate(R.layout.fragment_success_developer_registration, container, false); 

    btnDevGoProfile = (Button) rootView.findViewById(R.id.btnDevGoProfile); 

    btnDevGoProfile.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      dismiss(); 
      getFragmentManager().popBackStack(); 
      getActivity().finish(); 

      Profile fragment = (Profile) 
        getSupportFragmentManager().findFragmentByTag("ProfileFragment"); 

      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction() 
      transaction.detach(fragment); 
      transaction.attach(fragment); 
      transaction.commit(); 

     } 
    }); 

    return rootView; 
} 

}

は、私はgetSupportFragmentManagerが働いてイマイチ理由を知りません。それは、エラーがメソッドを解決できないことを示しています...私がgetFragmentManager()を使用したときにクラッシュします。あなたのdevの登録アクティビティで

+0

使用カスタムリスナーインタフェース –

+0

現在のフラグメントをリフレッシュするためにこれを試みることができますか – Cochi

答えて

0

また、あなたは、あなたのダイアログフラグメントのクラスをしてください共有することはできますか?

FragmentTransaction ftran = getActivity().getFragmentManager().beginTransaction(); 
ftran .detach(this).attach(this).commit(); 
0

、あなたのフラグメントを得る:

Profile profileFragment = getSupportFragmentManager().findFragmentByTag("ProfileFragment"); 

それをリフレッシュするために、あなたは試すことができます:

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 
transaction.detach(profileFragment); 
transaction.attach(profileFragment); 
transaction.commit(); 

はEDIT:

あなたはこれを試すことができますか?

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
    View rootView = inflater.inflate(R.layout.fragment_success_developer_registration, container, false); 

    btnDevGoProfile = (Button) rootView.findViewById(R.id.btnDevGoProfile); 



    return rootView; 
} 

@Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
     btnDevGoProfile.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      getActivity().getSupportFragmentManager().popBackStack(); 


      Profile fragment = (Profile) 
        getActivity().getSupportFragmentManager().findFragmentByTag("ProfileFragment"); 

      FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction() 
      transaction.detach(fragment); 
      transaction.attach(fragment); 
      transaction.commit(); 

      getActivity().finish(); 
      dismiss(); 

     } 
    }); 
    } 

これが役に立ちます。

+0

コードをDevRegistrationアクティビティまたはダイアログ・フラグメントに配置する必要がありますか?ダイアログのフラグメント内のボタンをクリックすると、コードを更新する必要があります。 –

+0

ダイアログフラグメントがDevRegistrationアクティビティにあります。 – Cochi

+0

私は本当に申し訳ありませんが、間違っている、私は私の質問を変更しました。 –

関連する問題