Jack Gao
Jack Gao

Reputation: 886

RoboGuice and ActionbarSherlock seems to not work together

Here is the thing:

I'm using roboguice-sherlock to work both ActionBarSherlock and RoboGuice, and want to use the @ContentView() feature of RoboGuice to inject the layout, also want to requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) in onCreate() to show Indeterminate progress bar.

After this, a runtime exception was caught:

java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

Is this a bug or I just doing wrong?

For example, in sample-roboguice of actionbarsherlock samples, if requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) is added in the onCreate() method just below super.onCreate(savedInstanceState), the sample crashes at runtime with the exceptions above.

Upvotes: 1

Views: 403

Answers (1)

Thomas Auinger
Thomas Auinger

Reputation: 41

Just call requestWindowFeature() before super.onCreate(). It should fix your problem.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    // do some epic things
}

Upvotes: 4

Related Questions