菊池
マップ用のエンプティアクティビティとマップフラグメントとして分けて作りました(googleMapの中でスクロールとかを入れれなかったので)
This commit is contained in:
parent
248666695e
commit
a05ee74ae1
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
|
@ -15,25 +14,24 @@
|
|||
tools:ignore="ExtraText"
|
||||
tools:targetApi="31" >
|
||||
|
||||
<!-- TODO: Before you run your application, you need a Google Maps API key.-->
|
||||
<!--
|
||||
TODO: Before you run your application, you need a Google Maps API key.
|
||||
|
||||
<!-- To get one, follow the directions here:-->
|
||||
To get one, follow the directions here:
|
||||
|
||||
<!-- https://developers.google.com/maps/documentation/android-sdk/get-api-key-->
|
||||
|
||||
<!-- Once you have your API key (it starts with "AIza"), define a new property in your-->
|
||||
<!-- project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the-->
|
||||
<!-- "YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".-->
|
||||
https://developers.google.com/maps/documentation/android-sdk/get-api-key
|
||||
|
||||
Once you have your API key (it starts with "AIza"), define a new property in your
|
||||
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
|
||||
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw" />
|
||||
|
||||
android:value="YOUR_API_KEY" />
|
||||
|
||||
<activity
|
||||
android:name=".Maps"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_maps" />
|
||||
android:name=".MapActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".TutorialActivity"
|
||||
android:exported="false" />
|
||||
|
@ -44,21 +42,18 @@
|
|||
android:name=".RootSearchActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".SetupActivity"
|
||||
android:name=".SetUpActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".CreateUUID"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.example.oplogy.DialogFragment"
|
||||
android:name=".DialogFragment"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
tools:ignore="DuplicateActivity" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -68,11 +63,3 @@
|
|||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
// セットアップのクリック処理
|
||||
if(view == setUp){
|
||||
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
||||
Intent toSetup = new Intent(MainActivity.this,SetupActivity.class);
|
||||
Intent toSetup = new Intent(MainActivity.this,SetUpActivity.class);
|
||||
startActivity(toSetup);
|
||||
|
||||
}
|
||||
|
|
14
app/src/main/java/com/example/oplogy/MapActivity.java
Normal file
14
app/src/main/java/com/example/oplogy/MapActivity.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MapActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.map_activity);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.example.oplogy.databinding.MapsBinding;
|
||||
|
||||
public class Maps extends FragmentActivity implements OnMapReadyCallback {
|
||||
|
||||
private GoogleMap mMap;
|
||||
private MapsBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = MapsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulates the map once available.
|
||||
* This callback is triggered when the map is ready to be used.
|
||||
* This is where we can add markers or lines, add listeners or move the camera. In this case,
|
||||
* we just add a marker near Sydney, Australia.
|
||||
* If Google Play services is not installed on the device, the user will be prompted to install
|
||||
* it inside the SupportMapFragment. This method will only be triggered once the user has
|
||||
* installed Google Play services and returned to the app.
|
||||
*/
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
|
||||
// Add a marker in Sydney and move the camera
|
||||
LatLng sydney = new LatLng(-34, 151);
|
||||
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
||||
}
|
||||
}
|
57
app/src/main/java/com/example/oplogy/MapsFragment.java
Normal file
57
app/src/main/java/com/example/oplogy/MapsFragment.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
public class MapsFragment extends Fragment {
|
||||
|
||||
private OnMapReadyCallback callback = new OnMapReadyCallback() {
|
||||
|
||||
/**
|
||||
* Manipulates the map once available.
|
||||
* This callback is triggered when the map is ready to be used.
|
||||
* This is where we can add markers or lines, add listeners or move the camera.
|
||||
* In this case, we just add a marker near Sydney, Australia.
|
||||
* If Google Play services is not installed on the device, the user will be prompted to
|
||||
* install it inside the SupportMapFragment. This method will only be triggered once the
|
||||
* user has installed Google Play services and returned to the app.
|
||||
*/
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
LatLng sydney = new LatLng(-34, 151);
|
||||
googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.maps_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
SupportMapFragment mapFragment =
|
||||
(SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
|
||||
if (mapFragment != null) {
|
||||
mapFragment.getMapAsync(callback);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,11 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class SetupActivity extends AppCompatActivity {
|
||||
public class SetUpActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.setup);
|
||||
setContentView(R.layout.activity_set_up);
|
||||
}
|
||||
}
|
43
app/src/main/res/layout/map_activity.xml
Normal file
43
app/src/main/res/layout/map_activity.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="10"
|
||||
tools:context=".MapActivity">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="10">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toMain"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_weight="4"
|
||||
android:textAlignment="center"
|
||||
android:text="🔙"
|
||||
android:textSize="50dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5"
|
||||
android:id="@+id/date"
|
||||
android:hint="今日の日付"
|
||||
android:textSize="40dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:map="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/map"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Maps" />
|
||||
android:id="@+id/map"
|
||||
tools:context=".MapsFragment"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"/>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SetupActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user