DroidParts has several variants of base Activities living in the following packages:

  • org.droidparts.activity.* - Android 2.2+ Activities & 3.0+ FragmentActivities.
  •* - Android 2.2+ with Android Support Library Fragments.
  •* - Android 2.2+ with Android Support Library Fragments & ActionBar.

By extending appropriate Activity, you get injection working. An alternative is calling Injector.inject(this);.

You’ll get an extra lifecycle method called onPreInject(). It’s used to set some data that should be present at injection time. Usually a layout.

private Button btn;

public void onPreInject() {

protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState); // <- btn is injected during this call.
   // Too late to set content view here.

Activity & FragmentActivity

There are variants of this class for pre-3.0 Androids with or w/o ActionBar support & for modern Androids. The versions with ActionBar support have the following extra methods:

  • setActionBarReloadMenuItem(MenuItem menuItem) - which MenuItem triggers reload, if any.
  • setActionBarLoadingIndicatorVisible(boolean visible) - show spinner for the item set on previous step.
  • setFragmentVisible(boolean visible, Fragment... fragments) - a shortcut method to show/hide Fragments.


Base class for Activities with only one Fragment.

  • F onCreateFragment() - implement to return a Fragment.


ActionBar-based tabs navigation with custom animation support.

  • addTab(ActionBar.Tab tab, Fragment... tabFragments) & addTab(int position, ActionBar.Tab tab, Fragment... tabFragments)
  • setCustomAnimations(int enter, int exit)
  • setCurrentTab(int position) & getCurrentTab()
  • onTabChanged(int position)