Themes wechseln bei "orientation

W

wirbelis_hund

Neues Mitglied
0
Schönen guten Tag zusammen,

ich habe ein kleines Problem, bei der Entwicklung von Apps.
Ich wollte gerne wenn ich die orientation wechseln von "protrait" in "landscape" das sich das Theme z.B. von "Theme.Holo" in "Theme.Holo.NoActionBar.Fullscreen" verändert.

Habe auch schon mehrere versuche gestartet mit Fragment, in der Androidmanifest mit configChanges, aber jedes mal wenn ich von "protrait" in "landscape" wechseln kommt der Fehler "source not found".

Das Merkwürdige ist wenn ich die App in "landscape" starte und von da in "protrait" wechsel funktioniert das komischer weiße, aber dreh ich dann das Handy wieder kommt wieder der Fehler "source not found" und ich weiß einfach nicht woran das liegen könnte.

Kann mir da jemand weiter helfen?

Mit freundlichen Grüßen wirbeli
 
Ohne auch nur anseitsweise zu wissen WO der fehler auftritt, kann man dir leider nicht helfen.

Wir brauchen etwas Source Code und LogCat
c3d13d266c691d8d88855452205d852e.jpg
 
ok.

Hier ist erst einmal der Code von der Manifest ...

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testapplication"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="14" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testapplication.MainActivity"
            android:label="@string/app_name"
            android:configChanges="orientation" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Dann der Code von meiner MainActivity

Code:
@Override
	protected void onCreate(Bundle savedInstanceState) {
		if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
			setTheme(android.R.style.Theme_Holo_NoActionBar_Fullscreen);
		} else {
			setTheme(android.R.style.Theme_Holo);
		}
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_activity);
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
	}

und jetzt ein Ausschnitt vom LogCat mit der Fehlermeldung:
Code:
05-16 14:44:17.192: E/SpannableStringBuilder(5595): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-16 14:44:17.192: E/SpannableStringBuilder(5595): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-16 14:44:28.497: E/AndroidRuntime(5595): FATAL EXCEPTION: main
05-16 14:44:28.497: E/AndroidRuntime(5595): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapplication/com.example.testapplication.MainActivity}: java.lang.NullPointerException
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2107)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3573)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.access$800(ActivityThread.java:140)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.os.Looper.loop(Looper.java:137)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.main(ActivityThread.java:4918)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at java.lang.reflect.Method.invokeNative(Native Method)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at java.lang.reflect.Method.invoke(Method.java:511)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at dalvik.system.NativeStart.main(Native Method)
05-16 14:44:28.497: E/AndroidRuntime(5595): Caused by: java.lang.NullPointerException
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at com.android.internal.policy.impl.PhoneWindow$PanelFeatureState.onRestoreInstanceState(PhoneWindow.java:3741)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at com.android.internal.policy.impl.PhoneWindow.restorePanelState(PhoneWindow.java:1890)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1841)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.Activity.onRestoreInstanceState(Activity.java:968)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.Activity.performRestoreInstanceState(Activity.java:940)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1145)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2085)
05-16 14:44:28.497: E/AndroidRuntime(5595): 	... 12 more

Und wie gesagt wenn ich die App erst einmal im "landscape" starte und in "portrait" wechseln tritt der Fehler nicht auf, aber will ich von "portrait" in "landscape" funktioniert das nicht.

Danke für die Hilfe im voraus
 
k, danke werde es nochmal damit versuchen, hatte das schon mal versucht mit den Ordner aber da kam genau das gleiche Problem, aber gerade ist mir noch was dazu eingefallen :D

Der ursprüngliche Beitrag von 14:54 Uhr wurde um 15:54 Uhr ergänzt:

So habe es jetzt nochmal mit den 2 ordnern versucht "layout-land" und "layout-port" haben zwei Styles erstellt und die im layout zugewiesen aber der Fehler besteht weiterhin.

Code Ausschnitt von der Style.xml

Code:
<style name="Portrait" parent="android:Theme.Holo" />
    
    <style name="Landscape" parent="android:Theme.Holo.NoActionBar.Fullscreen" />

Code Ausschnitt von layout.xml

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    style="@style/Landscape" >
    

</LinearLayout>

so sieht die Portrait auch aus nur das stand @style/Landscape ... portrait dort steht...

und der Fehler im Logcat ist wie folgt
Code:
05-16 15:54:00.469: E/SpannableStringBuilder(9403): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-16 15:54:00.469: E/SpannableStringBuilder(9403): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-16 15:54:07.031: E/AndroidRuntime(9403): FATAL EXCEPTION: main
05-16 15:54:07.031: E/AndroidRuntime(9403): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapplication/com.example.testapplication.MainActivity}: java.lang.NullPointerException
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2107)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3573)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.access$800(ActivityThread.java:140)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.os.Looper.loop(Looper.java:137)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.main(ActivityThread.java:4918)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at java.lang.reflect.Method.invokeNative(Native Method)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at java.lang.reflect.Method.invoke(Method.java:511)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at dalvik.system.NativeStart.main(Native Method)
05-16 15:54:07.031: E/AndroidRuntime(9403): Caused by: java.lang.NullPointerException
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at com.android.internal.policy.impl.PhoneWindow$PanelFeatureState.onRestoreInstanceState(PhoneWindow.java:3741)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at com.android.internal.policy.impl.PhoneWindow.restorePanelState(PhoneWindow.java:1890)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1841)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.Activity.onRestoreInstanceState(Activity.java:968)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.Activity.performRestoreInstanceState(Activity.java:940)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1145)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2085)
05-16 15:54:07.031: E/AndroidRuntime(9403): 	... 12 more
 
Interessant, ich würde mal den Android SourceCode mit einbinden und den Debugger anschmeißen und den Android Code debuggen und schauen was da genau null ist.
 
Hm, hab jetzt ne andere Lösung gefunden ...
hab das Problem jetzt mit getWindow und getActionbar gelöst!

Trotzdem Danke für die Hilfe
 

Ähnliche Themen

D
Antworten
17
Aufrufe
429
datNeMo
D
M
Antworten
3
Aufrufe
200
moin
M
Y
Antworten
4
Aufrufe
1.244
swa00
swa00
Zurück
Oben Unten