ここの例を使用してフラグメントを切り替えようとしています:
http://developer.android.com/guide/components/fragments.html
しかし、それは機能しません:
Fragment newFragment = new ExampleFragment();
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(android.R.id.content, newFragment);
transaction.addToBackStack(null);
transaction.commit();
エラーが発生します:
The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, Fragment)
だから私はこれを修正します:
android.app.Fragment newFragment = new ExampleFragment();
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(android.R.id.content, newFragment);
transaction.addToBackStack(null);
transaction.commit();
ExampleFragment の型が間違っているという別のエラーが発生するので、次のように変更します。
ExampleFragment newFragment = new ExampleFragment();
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(android.R.id.content, newFragment);
transaction.addToBackStack(null);
transaction.commit();
そして、それはすべてループし続けます。修正方法は何ですか?