# neuen view öffnen



## noobee (6. Jun 2012)

ich habe mir neben der main.xml noch eine dump2.xml erstellt und diese auch mal mit buttons & co belegt.

wie kann ich jetzt mit einem buttonclick in der main.xml die dump2.xml öffnen ?
hatte es mit 
	
	
	
	





```
openContextMenu
```
 und 
	
	
	
	





```
openOptionsMenu
```
 probiert -.- na gut, dass war wohl definitiv nicht das richtge ???:L


----------



## Dagobert (6. Jun 2012)

Meinst du wie man Activities untereinander aufruft? oder möchtest du einfach nur das Layout ändern?

Du brauchst einen Listener für den Button und kannst dann mit einem Intent eine neue Activity aufrufen...

mfg. Dagobert


----------



## noobee (6. Jun 2012)

öh ja, war wohl blöd beschrieben 

genau, ich möchte aus meiner "haupt"activity eben eine bereits erstellte aufrufen.


----------



## Dagobert (6. Jun 2012)

Okay guck dir das mal an 

Activity Starten

mfg. Dagobert


----------



## noobee (6. Jun 2012)

mhh, ich komm da grad nicht weiter  sieht jemand den fehler ? die neue activity "laenge" geht icht auf und das prog stürzt ab


```
public class UltimateConverterActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button1;
        button1 = (Button)findViewById(R.id.button1);
        button1.setOnClickListener(this);
        
        Button btnActivity = (Button)findViewById(R.id.button2);
        btnActivity.setOnClickListener(new View.OnClickListener() {
			
        	@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent in = new Intent(startActivity(), laenge.class);
				startActivity(in);
			}
		})
    }
```


----------



## Dagobert (6. Jun 2012)

Gerade sah es noch schöner aus...
poste mal bitte die ganze Activity und die aufzurufende Activity

mfg. Dagobert


----------



## noobee (6. Jun 2012)

haaaaaaaaaaaaaaaaaa, ich habs   

hab hier noch ne schöne anleitung gefunden  deine und die gefundene habens gebracht

Android Start Activity

jetzt öffnet sich die 2. activity

so sieht der code jetzt aus

```
public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button1;
        button1 = (Button)findViewById(R.id.button1);
        button1.setOnClickListener(this);
        
        ///////////////////////////////////////////////////////////
        ///
        /// 2. Activity starten
        ///
        ///////////////////////////////////////////////////////////
        Button btnActivity = (Button)findViewById(R.id.button2);
        btnActivity.setOnClickListener(new View.OnClickListener()
        {
			public void onClick(View v)
			{
				// TODO Auto-generated method stub
				Intent in = new Intent
						(
								UltimateConverterActivity.this,
								laenge.class
						 );
				startActivity(in);
			}
		}
        );
    }
```


----------



## Dagobert (6. Jun 2012)

lass uns teilhaben an deiner Ausführung 
vllt. wirds dir auch mal wer danken 

mfg. Dagobert


----------



## noobee (6. Jun 2012)

ich hatte noch vergessen, die neue Activity in der Android Manifest Datei hinzufügen. vllt deshalb immer der absturz


----------



## Dagobert (6. Jun 2012)

Ja das kann gut sein.
Aber noch eine Anmerkung am Rande, in Java werden Klassen groß geschrieben 

mfg. Dagobert


----------



## noobee (7. Jun 2012)

ich bekomme beim ausführen immer einen absturz, jedoch gibt es unter "problems" keine meldungen.
wie sehe ich denn jetzt, was dort passiert bzw. nicht passiert ist ?


----------



## schlingel (7. Jun 2012)

Logcat


----------



## noobee (8. Jun 2012)

ach du schei*e :shock: :shock:

also ich hab erstmal ne mega volle logcat. wenn ich mir nur errors anzeigen lasse platzt mir schon der kopf, da ich gefühlte 1000 meldungen sehe :autsch::autsch:


```
06-06 20:58:13.534: E/ApplicationContext(597): Couldn't create directory for SharedPreferences file shared_prefs/wallpaper-hints.xml
06-06 20:58:12.221: E/ActivityThread(680): Failed to find provider info for android.server.checkin
06-06 20:58:13.521: E/ActivityThread(680): Failed to find provider info for android.server.checkin
06-06 20:58:13.981: E/ActivityThread(680): Failed to find provider info for android.server.checkin
06-06 20:58:14.681: E/ActivityThread(680): Failed to find provider info for android.server.checkin
06-06 20:58:14.761: E/ActivityThread(680): Failed to find provider info for android.server.checkin
06-06 21:23:55.951: E/AndroidRuntime(802): Uncaught handler: thread main exiting due to uncaught exception
06-06 21:23:55.961: E/AndroidRuntime(802): java.lang.RuntimeException: Unable to start activity ComponentInfo{icke.namespace/icke.namespace.UlCoActivity}: java.lang.NullPointerException
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread.access$1800(ActivityThread.java:112)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.os.Looper.loop(Looper.java:123)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread.main(ActivityThread.java:3948)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at java.lang.reflect.Method.invoke(Method.java:521)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at dalvik.system.NativeStart.main(Native Method)
06-06 21:23:55.961: E/AndroidRuntime(802): Caused by: java.lang.NullPointerException
06-06 21:23:55.961: E/AndroidRuntime(802): 	at icke.namespace.UlCoActivity.onCreate(UlCoActivity.java:23)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-06 21:23:55.961: E/AndroidRuntime(802): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-06 21:23:55.961: E/AndroidRuntime(802): 	... 11 more
06-06 21:24:01.181: E/AndroidRuntime(837): Uncaught handler: thread main exiting due to uncaught exception
06-06 21:24:01.201: E/AndroidRuntime(837): java.lang.RuntimeException: Unable to start activity ComponentInfo{icke.namespace/icke.namespace.UlCoActivity}: java.lang.NullPointerException
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread.access$1800(ActivityThread.java:112)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.os.Looper.loop(Looper.java:123)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread.main(ActivityThread.java:3948)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at java.lang.reflect.Method.invoke(Method.java:521)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at dalvik.system.NativeStart.main(Native Method)
06-06 21:24:01.201: E/AndroidRuntime(837): Caused by: java.lang.NullPointerException
06-06 21:24:01.201: E/AndroidRuntime(837): 	at icke.namespace.UlCoActivity.onCreate(UlCoActivity.java:23)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-06 21:24:01.201: E/AndroidRuntime(837): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-06 21:24:01.201: E/AndroidRuntime(837): 	... 11 more
06-06 21:27:12.912: E/AndroidRuntime(877): Uncaught handler: thread main exiting due to uncaught exception
06-06 21:27:12.912: E/AndroidRuntime(877): java.lang.RuntimeException: Unable to start activity ComponentInfo{icke.namespace/icke.namespace.UlCoActivity}: java.lang.NullPointerException
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread.access$1800(ActivityThread.java:112)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.os.Looper.loop(Looper.java:123)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread.main(ActivityThread.java:3948)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at java.lang.reflect.Method.invoke(Method.java:521)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at dalvik.system.NativeStart.main(Native Method)
06-06 21:27:12.912: E/AndroidRuntime(877): Caused by: java.lang.NullPointerException
06-06 21:27:12.912: E/AndroidRuntime(877): 	at icke.namespace.UlCoActivity.onCreate(UlCoActivity.java:23)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-06 21:27:12.912: E/AndroidRuntime(877): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-06 21:27:12.912: E/AndroidRuntime(877): 	... 11 more
06-06 21:28:01.131: E/AndroidRuntime(943): Uncaught handler: thread main exiting due to uncaught exception
06-06 21:28:01.131: E/AndroidRuntime(943): java.lang.RuntimeException: Unable to start activity ComponentInfo{icke.namespace/icke.namespace.UlCoActivity}: java.lang.NullPointerException
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread.access$1800(ActivityThread.java:112)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.os.Looper.loop(Looper.java:123)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread.main(ActivityThread.java:3948)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at java.lang.reflect.Method.invoke(Method.java:521)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at dalvik.system.NativeStart.main(Native Method)
06-06 21:28:01.131: E/AndroidRuntime(943): Caused by: java.lang.NullPointerException
06-06 21:28:01.131: E/AndroidRuntime(943): 	at icke.namespace.UlCoActivity.onCreate(UlCoActivity.java:23)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-06 21:28:01.131: E/AndroidRuntime(943): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-06 21:28:01.131: E/AndroidRuntime(943): 	... 11 more
06-06 21:28:35.731: E/AndroidRuntime(973): ERROR: thread attach failed
06-06 21:28:35.841: E/jdwp(980): Failed sending req to debugger: Broken pipe (-1 of 27)
06-06 21:28:35.841: E/jdwp(980): Failed sending reply to debugger: Broken pipe
06-06 21:28:36.021: E/AndroidRuntime(980): Uncaught handler: thread main exiting due to uncaught exception
06-06 21:28:36.021: E/AndroidRuntime(980): java.lang.RuntimeException: Unable to start activity ComponentInfo{icke.namespace/icke.namespace.UlCoActivity}: java.lang.NullPointerException
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread.access$1800(ActivityThread.java:112)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.os.Looper.loop(Looper.java:123)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread.main(ActivityThread.java:3948)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at java.lang.reflect.Method.invoke(Method.java:521)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at dalvik.system.NativeStart.main(Native Method)
06-06 21:28:36.021: E/AndroidRuntime(980): Caused by: java.lang.NullPointerException
06-06 21:28:36.021: E/AndroidRuntime(980): 	at icke.namespace.UlCoActivity.onCreate(UlCoActivity.java:23)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-06 21:28:36.021: E/AndroidRuntime(980): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
06-06 21:28:36.021: E/AndroidRuntime(980): 	... 11 more
```

und ich als blutiger anfänger kann damit eigentlich nichts anfangen ???:L da waren mir die fehler, welche es in der "problems" übersicht angezeigt hat lieber und leichter zu verstehen/zu korrigieren

also vllt kann mir hier einer weiterhelfen


----------



## schlingel (8. Jun 2012)

Outch, der Stack-Trace sieht tatsächlich wilder aus als bei "normalen" Fehlern.

Fang einfach von unten an und beginne die NPE auszubessern. Es steht eh immer dabei in welchem deiner Files in welcher Zeile der Fehler aufgetreten ist.


----------

