6
votes

Utilisation d'ActionBarCompat et de demandeWindowFeature

Jusqu'à présent, je n'avais plus de problèmes plus gros émouvant d'Actionbarcherlock à ActionbarCompat. Sur mon Nexus 4, ça marche plutôt bien. Alors que j'ai commencé à tester sur mon ancien Nexus, on courir 2.3.6 J'ai couru dans un problème lorsque je fais pivoter l'appareil. Je demande une fonctionnalité de fenêtre pour afficher la progression intermédiaire dans la barre d'action:

08-12 13:34:09.242: E/AndroidRuntime(4602): FATAL EXCEPTION: main
08-12 13:34:09.242: E/AndroidRuntime(4602): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.app.packagename/net.app.fragment.CustomActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2832)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.access$1600(ActivityThread.java:117)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.os.Looper.loop(Looper.java:130)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at java.lang.reflect.Method.invokeNative(Native Method)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at java.lang.reflect.Method.invoke(Method.java:507)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at dalvik.system.NativeStart.main(Native Method)
08-12 13:34:09.242: E/AndroidRuntime(4602): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
08-12 13:34:09.242: E/AndroidRuntime(4602):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.Activity.requestWindowFeature(Activity.java:2729)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at net.app.fragment.BaseFragmentActivity.onCreate(BaseFragmentActivity.java:50)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at net.app.fragment.CustomActivity.onCreate(CustomActivity.java:55)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-12 13:34:09.242: E/AndroidRuntime(4602):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-12 13:34:09.242: E/AndroidRuntime(4602):     ... 12 more
08-12 13:34:12.092: I/Process(4602): Sending signal. PID: 4602 SIG: 9


0 commentaires

4 Réponses :


12
votes

appel suppormetteurswindowfeature (fenêtre.Feature _...) .

voir http: // Android -Devopopers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html


0 commentaires

0
votes

Utiliser SupporRequestWindowFeature (fenêtreCompat.feature_xxx)

I.e. Vous devez également utiliser windowcompat.feature_xxx au lieu de fenêtre.feature_xxx pour la comptabilité en arrière.


0 commentaires

0
votes

pour ceux qui n'appellent pas demandewindowfreatu () méthode mais obtenez toujours l'exception, essayez cette solution de contexte: xxx

voir https://code.google.com/p/android/issues/detail?id=60841


0 commentaires

0
votes

Le journal des erreurs indique clairement 'DemandeFeature () doit être appelé avant d'ajouter du contenu'. Donc, vous devez appeler 'Super.Oncreate (SavedInstanCetate);' après les appels «DemandeWindowFeature». Et il n'est pas nécessaire d'appeler SupporRequestwindowFeature (fenêtre.Feature _...) comme mentionné ci-dessus. Voir le code de travail ci-dessous.

  @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        requestWindowFeature(Window.FEATURE_PROGRESS);
        super.onCreate(savedInstanceState);


0 commentaires