Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Process: com.example.yihanwang.myapplication, PID: 20971
- android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class fragment
- at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
- at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
- at com.example.yihanwang.myapplication.MapActivity.onCreateView(MapActivity.java:40)
- at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
- at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
- public class MapFragment extends Fragment implements OnMapReadyCallback {
- private GoogleMap m_cGoogleMap;
- private Button toImage, toHome;
- private static final LatLng LOCATION_GRAMPIANS
- = new LatLng(-37.6145,142.3244);
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.activity_map, container, false);
- // Get access to our MapFragment
- SupportMapFragment mapFrag = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map_fragment);
- // Set up an asyncronous callback to let us know when the map has loaded
- mapFrag.getMapAsync(this);
- toImage = (Button)view.findViewById(R.id.findPlant);
- toHome = (Button)view.findViewById(R.id.goBack);
- toImage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Fragment fragment = new ImageFragment();
- FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
- fragmentManager.beginTransaction()
- .replace(R.id.frame_container, fragment).addToBackStack("Image").commit();
- }
- });
- toHome.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- getFragmentManager().popBackStack();
- }
- });
- return view;
- }
- @Override
- public void onMapReady(GoogleMap googleMap) {
- // Function is called once the map has fully loaded.
- // Set our map object to reference the loaded map
- m_cGoogleMap = googleMap;
- // Move the focus of the map to be on the Grampians park. 15 is for zoom
- m_cGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LOCATION_GRAMPIANS,15));
- m_cGoogleMap.addMarker(new MarkerOptions().position(LOCATION_GRAMPIANS).title("You Are Here"));
- //set map to satellite map
- m_cGoogleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
- }
- }
- <?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"
- tools:context="com.example.yihanwang.myapplication.MapActivity">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
- <fragment
- android:id="@+id/map_fragment"
- android:name="com.google.android.gms.maps.SupportMapFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="120px"
- android:background="#45104502"
- android:orientation="horizontal">
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal"
- android:gravity="center">
- <Button
- android:id="@+id/goBack"
- android:layout_width="70px"
- android:layout_height="80px"
- android:background="@drawable/back"
- android:onClick="toGoBack" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal"
- android:gravity="center">
- <Button
- android:id="@+id/findPlant"
- android:layout_width="70px"
- android:layout_height="80px"
- android:background="@drawable/flowr"
- android:onClick="toImagePage" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal"
- android:gravity="center">
- <Button
- android:id="@+id/plantList"
- android:layout_width="90px"
- android:layout_height="100px"
- android:background="@drawable/list" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement