Hallo,
so hier mal mein code. Vorab auf den Button ist ein onClick in XML implementiert.
Der nachfolgende CODE Abschnitt ist in der Methode WeiterButtonClick
if (FragenManager.GetCurrentQuestionNumber() == 14) {
Button weiterBtn = (Button) findViewById(R.id.Weiter);
weiterBtn.setText("Auswerten");
weiterBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
startActivity(intent);
}
});
}
Hier meine Manifest!
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
<activity
android:name="com.example.einstufungstestmathematik.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.einstufungstestmathematik.TestActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:parentActivityName="com.example.einstufungstestmathematik.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.einstufungstestmathematik.MainActivity" />
</activity>
<activity
android:name="com.example.einstufungstestmathematik.ResultActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:parentActivityName="com.example.einstufungstestmathematik.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.einstufungstestmathematik.TestActivity" />
</activity>
<activity
android:name="com.example.einstufungstestmathematik.ResultSingleQuestionActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:parentActivityName="com.example.einstufungstestmathematik.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.einstufungstestmathematik.ResultActivity" />
</activity>
<activity
android:name="com.example.einstufungstestmathematik.ManualActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:parentActivityName="com.example.einstufungstestmathematik.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.einstufungstestmathematik.MainActivity" />
</activity>
</application>
und hier mein XML Code des Buttons
<Button
android:id="@+id/Weiter"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginLeft="2dp"
android:text="@string/Weiter"
android:layout_weight="0.5"
style="?android:attr/borderlessButtonStyle"
android:onClick="WeiterButtonClick"/>
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.