I had a ListActivity where when I pressed one button, I started an intent showing another ListActivity. Now, I have to change these ListActivities to ListFragments. I do this to inflate the layout:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/**Inflate the layout for this fragment*/
return inflater.inflate(R.layout.recent_calls, container, false);
}
And to start the intent, now, as I a fragment, I do this:
CallDetailActivity Fragment_detail = new CallDetailActivity();
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.replace(R.id.recent_calls, Fragment_detail);
transaction.addToBackStack(null);
transaction.commit();
My question is, where I put R.id.recent_calls
in replace, I'm calling to the FrameLayout id of the same layout that I have initialized with the onCreateView. Is this ok? Or there would be another way to replace the actual layout with another when using fragments? something like the intent does for the activites.
UPDATE--
I'm having an error on the .replace
as it is showing me "The method replace(int, fragment) in the type fragmenttransaction is not applicable for the arguments (int, CallDeateilActivity)"
UPDATE 2--
<FrameLayout
android:id="@+id/recent_calls"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay"/>
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Call log is empty"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"/>