Reputation: 5849
I have 2 activities which extend a base activity:
Class BaseActivity extends Activity
Class A extends BaseActivity
Class B extends BaseActivity
Now I have a button on A which allows the user to go to B, and a button on B which allows to go back to A.
So far, so good.
Now after reading this documentation, which is straightforward enough, I am implementing an additional activity between BaseActivity and A, B. The structure will be:
Class BaseActivity extends Activity
Class MyDrawer extends BaseActivity
Class A extends MyDrawer
Class B extends MyDrawer
The activity MyDrawer contains the code to use a Navigation Drawer. The problem I have is, I am not able to understand how do I use my Activities instead of Fragments in the Navigation Drawer. I want the users to be able to switch between activities through the drawer. Is this possible? or do I need to rewrite everything using Fragments instead of Activities?
Any help is appreciated.
Upvotes: 2
Views: 1081
Reputation: 819
Use intent's to switch between the activities. Refer to Navigation Drawer to switch between activities
public void selectItem(int position) {
Intent intent = null;
switch(position) {
case 0:
intent = new Intent(this, Activity_0.class);
break;
case 1:
intent = new Intent(this, Activity_1.class);
break;
...
case 4:
intent = new Intent(this, Activity_4.class);
break;
default :
intent = new Intent(this, Activity_0.class); // Activity_0 as default
break;
}
startActivity(intent);
}
Upvotes: 0