I have an android application project that also has a few android library projects. Each library project has it's own activities and resources. I've implemented the NavigationDrawer
and would like to have it on all activities, so I created a base project (android library project) that has the drawer (following the guides in this answer: Same Navigation Drawer in different Activities). Then the idea is that each sub project (android library projects) will extend from the base but at this point I am hitting the circular reference problem.
I have a similar structure as on this image:
There's no problem to have each activity in the Sub projects to extend from the Base library, but the problem is that the Base library also needs to know the activities(hence the circular reference), so that I can handle the clicks in the NavigationDrawer
, something similar to that:
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
Intent intent = new Intent(this, SubProjectOneActivityOne.class);
startActivity(intent);
finish();
break;
case 1:
Intent intent1 = new Intent(this, SubProjectOneActivityTwo.class);
startActivity(intent1);
break;
case 2:
Intent intent2 = new Intent(this, SubProjectTwoActivityOne.class);
startActivity(intent2);
break;
default:
break;
}
}});
So at the moment I am hitting a dead end with this approach. Could it be possible to overload the click event in the sub projects? Does anybody have other suggestions?