Android Activity wechseln per Button

drugnkush

Neues Mitglied
Hallo liebe Community,
ich habe aktuell ein Problem undzwar ich möchte wenn man auf den "BACK" Button drückt das man zurück zur MainActivity kommt von der CreditsActivity.
Die Funktion funktioniert aus welchen Gründen auch immer nicht.
Per Button in die Credits komme ich (ist ja der gleiche Befehl) aber der "Back" Button funktioniert nicht um ins Hauptmenü wieder zu kommen!
Ich bitte um Hilfe.
Mfg Martin.
mlgforumhilfe.png
 
Zuletzt bearbeitet:

Elenteria

Bekanntes Mitglied
Über setContentView wechselt man auch nicht die Activity sondern setzt das Layout bzw. die View mit dem anzuzeigenden Inhalt.
Zwischen Activities wechselt man über Intents und der startActivity()-Methode.
In deinem Fall würde das so aussehen
Java:
Intent i = new Intent(CreditsActivity.this, MainActivity.class);
StartActivity(i);
 

buggy84

Bekanntes Mitglied
Du musst Dir das

http://developer.android.com/guide/components/activities.html

und das

http://developer.android.com/guide/components/tasks-and-back-stack.html

nochmal anschauen und verstehen. Vor allem den BackStack.
Sehr gutes Beispiel in der Anwendung:

http://www.androidhive.info/2011/08/how-to-switch-between-activities-in-android/

mit finish() bist du auf dem richtigen Weg, die Frage ist nur... was ist dein Hauptmenü und wo liegt es im BackStack?

Das hier ist auch ziemlich gut, aber das baut auf die oberen Links auf. Erstmal die abarbeiten.

http://stackoverflow.com/questions/11366700/modification-of-the-back-stack-in-android
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
S Android "Weiches wechseln" zwischen Views in einer Activity Android & Cross-Platform Mobile Apps 3
M Activity wechseln aus List View mit Android & Cross-Platform Mobile Apps 2
W JSONARRAY per Intent an andere Activity übergeben und umwandeln ggbf. Android & Cross-Platform Mobile Apps 1
M Activity einer anderen App mit result Android & Cross-Platform Mobile Apps 2
CT9288 Methode von Fragment durch Activity rufen scheitert Android & Cross-Platform Mobile Apps 7
ruutaiokwu Android Daten von "Activity A" nach "Activity B" umleiten? Android & Cross-Platform Mobile Apps 13
L Android Lockscreen-Sperrmuster activity verwenden Android & Cross-Platform Mobile Apps 1
J Android App stürzt ab wenn neue activity gestartet Android & Cross-Platform Mobile Apps 6
P Android Android-App Crash - Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 2
S Neue Activity lässt sich nicht starten Android & Cross-Platform Mobile Apps 28
B Android Activity nach gedrückte Returntaste weiterlaufen lassen Android & Cross-Platform Mobile Apps 2
J Probleme mit ViewPager und Activity Android & Cross-Platform Mobile Apps 1
B Android In einem View der ersten Activity zweite anzeigen Android & Cross-Platform Mobile Apps 2
G Accelerometer ohne Activity Android & Cross-Platform Mobile Apps 8
J Android BroadcastHandler extends BroadcastReceiver; auf Activity zugreifen? Android & Cross-Platform Mobile Apps 5
K Android Übergeordnete Activity herausfinden? Android & Cross-Platform Mobile Apps 7
W Android Designfrage / Layout / Activity / Fragments Android & Cross-Platform Mobile Apps 2
B Login Activity Android & Cross-Platform Mobile Apps 1
M Android Suche Activity/View Namen Android & Cross-Platform Mobile Apps 1
K Unbekannte Menge von Daten (Strings oder Ints) an Activity übergeben Android & Cross-Platform Mobile Apps 0
M Fehler ohne Sinn? java.lang.RuntimeException: Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 11
S Android Eclipse erstellt keine main Activity Android & Cross-Platform Mobile Apps 4
B java.lang.RuntimeException: Unable to start activity ComponentInfo Android & Cross-Platform Mobile Apps 2
K Android Activity for result aus Dialog Android & Cross-Platform Mobile Apps 1
D Android Activity mit mehreren Views "spliten" Android & Cross-Platform Mobile Apps 10
G Activity-Wechsel bitte ohne Notification Android & Cross-Platform Mobile Apps 6
G eine Methode einer anderen Activity aufrufen Android & Cross-Platform Mobile Apps 9
D Android Neue Activity im TabWidget laden Android & Cross-Platform Mobile Apps 8
S Android In Service überprüfen ob eine Activity gebunden ist? Android & Cross-Platform Mobile Apps 6
T Android Activity finished testen Android & Cross-Platform Mobile Apps 5
T Activity / Application fundamentals Android & Cross-Platform Mobile Apps 4
G extends Activity für Berechnungen? Android & Cross-Platform Mobile Apps 7
G Daten von einer Activity zur nächsten übergeben Android & Cross-Platform Mobile Apps 6
G selbes Menü auf jeder Activity Android & Cross-Platform Mobile Apps 4
C Activity ohne Aktion starten Android & Cross-Platform Mobile Apps 8
C Android Kommunikation zwischen Service und Activity Android & Cross-Platform Mobile Apps 8
Maxim6394 [ Android ] Activity ändern Android & Cross-Platform Mobile Apps 9
A Activity Intent 'source not found' Android & Cross-Platform Mobile Apps 4
A Android Activity Variablen-Initialisierung Android & Cross-Platform Mobile Apps 8
A Beenden einer 2ten Activity Android & Cross-Platform Mobile Apps 3
W Standard Gallery Activity? Android & Cross-Platform Mobile Apps 22
schlingel Android: Overlay in Activity Android & Cross-Platform Mobile Apps 3
G Activity beenden Android & Cross-Platform Mobile Apps 2
W aus Fragmente in andere Klasse wechseln mit Button Android & Cross-Platform Mobile Apps 3
K Bilder wechseln Android & Cross-Platform Mobile Apps 7
S Zur Homeansicht wechseln Android & Cross-Platform Mobile Apps 6
G Displayable wechseln. Mal gehts, mal nicht. Android & Cross-Platform Mobile Apps 2
T Android Studio: Einen Button in einer For Schleife verwenden Android & Cross-Platform Mobile Apps 2
W App deinstallieren per Button & Andere App Öffnen per Button Android & Cross-Platform Mobile Apps 24
W Apk automatisch installieren per Button Android & Cross-Platform Mobile Apps 55
T App updaten via Button Android & Cross-Platform Mobile Apps 10
AGW Android Teilen Button ändern Android & Cross-Platform Mobile Apps 14
A Button in SurfaceView integrieren Android & Cross-Platform Mobile Apps 10
J Android App - Browser öffnen und Text eingeben/Button click auslösen Android & Cross-Platform Mobile Apps 10
L Button zum Quadrad zwingen Android & Cross-Platform Mobile Apps 2
S Android Absoluter Neuling: EditText zur Laufzeit verändern bzw. über Button Android & Cross-Platform Mobile Apps 2
L Dialog anzeigen wenn auf Button gedrückt wird. Android & Cross-Platform Mobile Apps 4
S Android ListFragment & ArrayAdapter - Button-Werte werden vergessen Android & Cross-Platform Mobile Apps 0
B Android Abfragen wie lang ein Button gedrückt wurde Android & Cross-Platform Mobile Apps 2
J Android button mithilfe einer Methode automatisch erstellen Android & Cross-Platform Mobile Apps 6
A AlertDialog Enable Button Android & Cross-Platform Mobile Apps 1
J Button array ID Problem Android & Cross-Platform Mobile Apps 2
B Android ringProgressDialog nach Erfolg Button einfärben Android & Cross-Platform Mobile Apps 2
A Android Menü Button oben links Android & Cross-Platform Mobile Apps 1
B Mit Button GeräteEinstellung des Handys öffnen Android & Cross-Platform Mobile Apps 3
M Android Android "Up-Button" extra definieren? Android & Cross-Platform Mobile Apps 1
K Problem mit arraylist und button Android & Cross-Platform Mobile Apps 16
T Button aktivieren per Qullcode... Android & Cross-Platform Mobile Apps 3
T Button geht net... Android & Cross-Platform Mobile Apps 2
D Man sieht nicht ob Button gedrückt wurde! Android & Cross-Platform Mobile Apps 10
K Grafik Tablerow, Button erstreckt sich in der gesamten Breite trotz Beschrenkung durch (max)width Android & Cross-Platform Mobile Apps 2
G Button ein Wert zuweisen Android & Cross-Platform Mobile Apps 5
M 20 Image Button für jede Auflösung positionieren Android & Cross-Platform Mobile Apps 3
B Android Button erstellen nach Vorlage Android & Cross-Platform Mobile Apps 4
L Android Button mit Pfeil nach rechts Android & Cross-Platform Mobile Apps 1
M Einzel Verarbeitung welcher Button angeklickt wurde? Android & Cross-Platform Mobile Apps 6
G Back-Button Methode überschreiben Android & Cross-Platform Mobile Apps 2
P Android Option Button Android & Cross-Platform Mobile Apps 4
G Check Button ist unchecked trotz setChecked(true) Android & Cross-Platform Mobile Apps 6
G Android Button mit Bild Android & Cross-Platform Mobile Apps 4
W Android App Programmierung - Button ganz transparent machen Android & Cross-Platform Mobile Apps 3
L Custom Dialog Button event Android & Cross-Platform Mobile Apps 2
J Button rechtsbündig Android & Cross-Platform Mobile Apps 5
A Android Button Array? Android & Cross-Platform Mobile Apps 6
P Android Button mit bild versehen Android & Cross-Platform Mobile Apps 4
J "Button" auf List erstellen Android & Cross-Platform Mobile Apps 4
U Fire button und Command.BACK, 1 kommen sich in die quere Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben