I have a android studio project, and I have got few layouts which are connected to their .java files
note "I couldn't post images as of my low reputation"
I have got:
- layout1.xml
- layout2.xml
- layout3.xml
- layout4.xml
- layout5.xml
and
- Layout1.java
- Layout2.java
- Layout3.java
- Layout4.java
- Layout5.java
Android Manifest is:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@drawable/blablabla"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:screenOrientation="portrait"
android:name="com.icetea09.demomaterialdesigndrawermenu.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
layout1.xml code is this: "activity_main.xml is my layout1"
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mLvDrawerMenu = (ListView) findViewById(R.id.lv_drawer_menu);
List<DrawerMenuItem> menuItems = generateDrawerMenuItems();
mDrawerMenuAdapter = new DrawerMenuItemAdapter(getApplicationContext(), menuItems);
mLvDrawerMenu.setAdapter(mDrawerMenuAdapter);
mLvDrawerMenu.setOnItemClickListener(this);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.app_name, R.string.app_name) {
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if(savedInstanceState == null){
setFragment(0, BikeFragment.class);
}
}
The default layout load view is "layout1.xml with Layout1.java"
The question is how do I change the start view layout from layout1 to layout2. Like when I install the app first, It will show the "layout2.xml" view instead of default one which is layout1.xml in my case.
Thank you for your time.