Skip to content
Snippets Groups Projects
Commit ec2e3d0b authored by fheyming's avatar fheyming
Browse files

Added back button for logon and register

parent 87208ed9
Branches
No related tags found
1 merge request!1Mal aufn Master megren
package com.example.mampfmobil;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
......@@ -31,4 +32,11 @@ public class MainActivity extends AppCompatActivity {
}
@Override
public boolean onSupportNavigateUp() {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
return true; // true zurückgeben, um anzugeben, dass die Aktion behandelt wurde
}
}
\ No newline at end of file
package com.example.mampfmobil.ui.customer;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
......@@ -40,6 +42,13 @@ public class CustomerLogonFragment extends Fragment {
EditText lastname = rootView.findViewById(R.id.editTextLastName);
Button button = rootView.findViewById(R.id.buttonRegister);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
@Override
......
......@@ -60,6 +60,18 @@ public class CustomerOrdersFragment extends Fragment {
return rootView;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
// Hier kannst du den gewünschten Code ausführen, wenn der Zurück-Button gedrückt wird
// Zum Beispiel:
getActivity().onBackPressed(); // Rückwärtsnavigation durchführen
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
......
package com.example.mampfmobil.ui.customer;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import android.content.Intent;
......@@ -39,6 +41,13 @@ public class CustomerRegisterFragment extends Fragment {
EditText lastname = rootView.findViewById(R.id.editTextLastName);
EditText register = rootView.findViewById(R.id.editTextAddress);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
......
package com.example.mampfmobil.ui.deliverer;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
......@@ -42,6 +44,12 @@ public class DelivererLogonFragment extends Fragment {
EditText firstname = rootView.findViewById(R.id.editTextFirstName);
EditText lastname = rootView.findViewById(R.id.editTextLastName);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
......
package com.example.mampfmobil.ui.deliverer;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import android.content.Intent;
......@@ -38,6 +40,13 @@ public class DelivererRegisterFragment extends Fragment {
EditText lastname = rootView.findViewById(R.id.editTextLastName);
EditText register = rootView.findViewById(R.id.editTextAddress);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
@Override
......
package com.example.mampfmobil.ui.supplier;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
......@@ -41,6 +43,14 @@ public class SupplierLogonFragment extends Fragment {
Button button = rootView.findViewById(R.id.buttonRegister);
EditText firstname = rootView.findViewById(R.id.editTextFirstName);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
@Override
......
package com.example.mampfmobil.ui.supplier;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import android.content.Intent;
......@@ -39,6 +41,13 @@ public class SupplierRegisterFragment extends Fragment {
EditText name = rootView.findViewById(R.id.editTextFirstName);
EditText register = rootView.findViewById(R.id.editTextAddress);
AppCompatActivity activity = (AppCompatActivity) requireActivity();
// Enable the back button in the ActionBar
ActionBar actionBar = activity.getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
button.setOnClickListener(new View.OnClickListener() {
private Toast toast; //
@Override
......@@ -71,6 +80,8 @@ public class SupplierRegisterFragment extends Fragment {
return rootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment