Android Theme nicht mehr änderbar? Warum?

  • Antworten:6
Michele
  • Forum-Beiträge: 1.525

04.11.2013, 22:46:37 via Website

Hallo liebes Forum.


Seit Tagen suche ich mich bei Google dumm und doof :D:D.
Habe das Problem das ich meine Theme nicht mehr z.B zu
1android:theme="@android:style/Theme.Black.NoTitleBar" >
ändern kann.
Starte ich meine App, stürzt sie einfach ab.

Fehlermeldung ist von Android Studio:
111-04 22:43:31.179 7994-7994/com.example.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
2 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
3 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2092)
4 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
5 at android.app.ActivityThread.access$700(ActivityThread.java:134)
6 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
7 at android.os.Handler.dispatchMessage(Handler.java:99)
8 at android.os.Looper.loop(Looper.java:137)
9 at android.app.ActivityThread.main(ActivityThread.java:4867)
10 at java.lang.reflect.Method.invokeNative(Native Method)
11 at java.lang.reflect.Method.invoke(Method.java:511)
12 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
13 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
14 at dalvik.system.NativeStart.main(Native Method)
15 Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
16 at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
17 at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
18 at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
19 at com.example.myapplication.MainActivity.onCreate(MainActivity.java:19)
20 at android.app.Activity.performCreate(Activity.java:5047)
21 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
22 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
23            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
24            at android.app.ActivityThread.access$700(ActivityThread.java:134)
25            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
26            at android.os.Handler.dispatchMessage(Handler.java:99)
27            at android.os.Looper.loop(Looper.java:137)
28            at android.app.ActivityThread.main(ActivityThread.java:4867)
29            at java.lang.reflect.Method.invokeNative(Native Method)
30            at java.lang.reflect.Method.invoke(Method.java:511)
31            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
32            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
33            at dalvik.system.NativeStart.main(Native Method)

Komischerweise hatte ich das vor paar Wochen noch nicht.
Bei meinen "älteren" App´s klappt das wunderbar.
Warum ich das Theme ändern will? Z.B für die NumberPicker.
Da ändert sich der Style z.B dann.


Ich hoffe einer kann mir helfen und sagen wo das Problem liegt.
Finde einfach keine passende Antwort.


LG

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

04.11.2013, 23:02:34 via App

Musst du unbedingt die Theme ändern?
Ich dachte man könnte in er Styles Xml eigene styles definieren, ua. auch die Theme.

Edit da du die Support v7 nutzt, kann es sein dass die theme nicht erkannt wird,also lieber nochmal die support app neu importieren.

— geändert am 04.11.2013, 23:03:55

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten
Michele
  • Forum-Beiträge: 1.525

04.11.2013, 23:45:24 via Website

Theme ändern muss ich leider ja. Sagte ja warum.:D

In der styles.xml kann man das. Das ist richtig.
Aber was NumberPicker angeht, viel zu kompliziert.
Ansonsten habe ich das ja auch immer gemacht z.B für meine ProgressBars.

Was die Support v7 angeht, daran könnte es liegen. Wäre ich nie drauf gekommen.
Ich schaue mir das nachher mal an.
Habe mich damit zwar noch nie richtig befasst aber wird wohl mal Zeit.

Hoffe daran liegt es :D.

Danke dir erstmal für deine Hilfe.


LG

— geändert am 04.11.2013, 23:56:12

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

05.11.2013, 12:28:37 via Website

Steht auch in der Meldung:

You need to use a Theme.AppCompat theme (or descendant) with this activity

In dem Falle also z.b:

1<style name="SettingsTheme" parent="Theme.AppCompat.Light.DarkActionBar">

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten
Michele
  • Forum-Beiträge: 1.525

05.11.2013, 12:38:35 via Website

Mac Systems
Steht auch in der Meldung:

You need to use a Theme.AppCompat theme (or descendant) with this activity

In dem Falle also z.b:

1<style name="SettingsTheme" parent="Theme.AppCompat.Light.DarkActionBar">

Hallo Mac.

Danke dir.
Hatte ich ja auch schon versucht.
Ging aber nicht.

Werde mir das gleich alles nochmal unter die Lupe nehmen.

LG

Antworten
Michele
  • Forum-Beiträge: 1.525

06.11.2013, 00:48:07 via Website

So.

1<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

Ist schon Automatisch drin. Ganz vergessen.
Daran kann es also nicht liegen.


LG

— geändert am 06.11.2013, 00:53:57

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

06.11.2013, 11:43:33 via Website

Kann an sich nur an deiner XML liegen, hat du die richtigen ordner dafür ? Prüf mal die "vererbung" der themes. Ich hab meine auch logisch unterteilt so das ich weniger ändern muss wenn Ich das base theme ändere.

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten