I wanted to know how to call the base content_main.xml (layout) from the Navigation Drawer after calling other FragmentActivity.class, wherein the content_main.xml is the first view you'll see on starting the android application.
I can't do this because I think the Main Activity (MainActivity_Fragment.class) along with the NavigationDrawer extends AppCompatActivity... If you need a code I'll just display the code snippets... since the code too long.
If there's a way to call the default contentview, let me know... I searched google many times and unfortunately no answers... Please Help, thank you...
MainActivity_Fragment.class
public class MainActivity_Fragment extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,
SlideFragment.OnFragmentInteractionListener,
View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
...
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
//startActivity(new Intent(this, MainActivity_Fragment.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
FragmentTransaction transaction = getFragmentManager().beginTransaction();
MainActivity_Fragment newFragment = new MainActivity_Fragment();
transaction.replace(R.id.activity_translator, newFragment); // THIS IS THE ERROR WHEREIN MAINACTIVITY.CLASS SHOULD IMPLEMENT FRAGMENT
transaction.addToBackStack(null);
transaction.commit();
...
}
And this is my content_main.xml layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout_for_Fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/card_activity_background"
android:orientation="vertical"
tools:showIn="@layout/app_bar_main">
...// MY DEFAULT DISPLAY CONTENT
</LinearLayout>
Platform: Android Studio 2.2 Preview 5
Android SDK Target: 24
Min 15
NOTE: I didn't used FragmentActivity as extension of my Class, I simply used AppCompatActivity
I am not sure, I think it's in my own Activity, I should have re-code my MainActivity_Fragment.class
and extend it to FragmentActivity
.
But I'm still looking forward for the answer to not migrate to FragmentActivity
.