From 512ad3980f33f08705f79142de4a572371bbd9b5 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Wed, 16 Dec 2020 10:48:11 +0100 Subject: [PATCH] [FIX] mapview stuff --- .../com/a1/nextlocation/fragments/HomeFragment.java | 13 +++++++------ .../a1/nextlocation/fragments/SettingsFragment.java | 13 ++++++++++--- app/src/main/res/layout/fragment_home.xml | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java index 34a6f07..2fda536 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java @@ -1,11 +1,17 @@ package com.a1.nextlocation.fragments; + + import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -13,11 +19,6 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - import com.a1.nextlocation.R; import org.osmdroid.api.IMapController; @@ -69,7 +70,7 @@ public class HomeFragment extends Fragment { Configuration.getInstance().setUserAgentValue(userAgent); // create the map view - mapView = (MapView) view.findViewById(R.id.mapView); + mapView = view.findViewById(R.id.mapView); mapView.setDestroyMode(false); mapView.setTag("mapView"); mapView.setMultiTouchControls(true); diff --git a/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java index 3d1a436..721ba3e 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java @@ -2,6 +2,8 @@ package com.a1.nextlocation.fragments; import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; @@ -23,15 +25,20 @@ public class SettingsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + return inflater.inflate(R.layout.fragment_settings, container, false); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + // Inflate the layout for this fragment - View view = getView(); Spinner dropdown = view.findViewById(R.id.dropdown_menu_Settings); String[] items = new String[]{"Nederlands", "Engels", "Chinees"}; ArrayAdapter arrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items); dropdown.setAdapter(arrayAdapter); - - return inflater.inflate(R.layout.fragment_settings, container, false); } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 7a10442..2c9a701 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -6,7 +6,7 @@ tools:context=".fragments.HomeFragment"> -