Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. Process: com.example.yihanwang.myapplication, PID: 20971
  2.  
  3.  
  4.  
  5. android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class fragment
  6. at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
  7. at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
  8. at com.example.yihanwang.myapplication.MapActivity.onCreateView(MapActivity.java:40)
  9. at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
  10. at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
  11.  
  12. public class MapFragment extends Fragment implements OnMapReadyCallback {
  13. private GoogleMap m_cGoogleMap;
  14. private Button toImage, toHome;
  15.  
  16. private static final LatLng LOCATION_GRAMPIANS
  17. = new LatLng(-37.6145,142.3244);
  18.  
  19.  
  20. @Override
  21. public void onCreate(Bundle savedInstanceState) {
  22. super.onCreate(savedInstanceState);
  23. }
  24.  
  25. @Nullable
  26. @Override
  27. public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
  28. @Nullable Bundle savedInstanceState) {
  29. View view = inflater.inflate(R.layout.activity_map, container, false);
  30. // Get access to our MapFragment
  31. SupportMapFragment mapFrag = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map_fragment);
  32. // Set up an asyncronous callback to let us know when the map has loaded
  33. mapFrag.getMapAsync(this);
  34.  
  35. toImage = (Button)view.findViewById(R.id.findPlant);
  36. toHome = (Button)view.findViewById(R.id.goBack);
  37. toImage.setOnClickListener(new View.OnClickListener() {
  38. @Override
  39. public void onClick(View v) {
  40. Fragment fragment = new ImageFragment();
  41. FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
  42. fragmentManager.beginTransaction()
  43. .replace(R.id.frame_container, fragment).addToBackStack("Image").commit();
  44.  
  45. }
  46. });
  47.  
  48. toHome.setOnClickListener(new View.OnClickListener() {
  49. @Override
  50. public void onClick(View v) {
  51. getFragmentManager().popBackStack();
  52. }
  53. });
  54. return view;
  55. }
  56.  
  57. @Override
  58. public void onMapReady(GoogleMap googleMap) {
  59. // Function is called once the map has fully loaded.
  60. // Set our map object to reference the loaded map
  61. m_cGoogleMap = googleMap;
  62. // Move the focus of the map to be on the Grampians park. 15 is for zoom
  63. m_cGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LOCATION_GRAMPIANS,15));
  64.  
  65. m_cGoogleMap.addMarker(new MarkerOptions().position(LOCATION_GRAMPIANS).title("You Are Here"));
  66. //set map to satellite map
  67. m_cGoogleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
  68.  
  69. }
  70. }
  71.  
  72. <?xml version="1.0" encoding="utf-8"?>
  73. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  74. xmlns:app="http://schemas.android.com/apk/res-auto"
  75. xmlns:tools="http://schemas.android.com/tools"
  76. android:layout_width="match_parent"
  77. android:layout_height="match_parent"
  78. android:orientation="vertical"
  79. tools:context="com.example.yihanwang.myapplication.MapActivity">
  80.  
  81. <LinearLayout
  82. android:layout_width="match_parent"
  83. android:layout_height="wrap_content"
  84. android:layout_weight="1"
  85. android:orientation="horizontal">
  86.  
  87. <fragment
  88. android:id="@+id/map_fragment"
  89. android:name="com.google.android.gms.maps.SupportMapFragment"
  90.  
  91.  
  92. android:layout_width="match_parent"
  93. android:layout_height="match_parent"
  94. android:layout_alignParentBottom="true"
  95. android:layout_alignParentLeft="true"
  96. android:layout_alignParentStart="true" />
  97.  
  98. </LinearLayout>
  99.  
  100. <LinearLayout
  101. android:layout_width="match_parent"
  102. android:layout_height="120px"
  103. android:background="#45104502"
  104. android:orientation="horizontal">
  105.  
  106. <LinearLayout
  107. android:layout_width="wrap_content"
  108. android:layout_height="match_parent"
  109. android:layout_gravity="center"
  110. android:layout_weight="1"
  111. android:orientation="horizontal"
  112. android:gravity="center">
  113.  
  114. <Button
  115. android:id="@+id/goBack"
  116. android:layout_width="70px"
  117. android:layout_height="80px"
  118. android:background="@drawable/back"
  119. android:onClick="toGoBack" />
  120. </LinearLayout>
  121.  
  122. <LinearLayout
  123. android:layout_width="wrap_content"
  124. android:layout_height="match_parent"
  125. android:layout_gravity="center"
  126. android:layout_weight="1"
  127. android:orientation="horizontal"
  128. android:gravity="center">
  129.  
  130. <Button
  131. android:id="@+id/findPlant"
  132. android:layout_width="70px"
  133. android:layout_height="80px"
  134. android:background="@drawable/flowr"
  135. android:onClick="toImagePage" />
  136. </LinearLayout>
  137.  
  138. <LinearLayout
  139. android:layout_width="wrap_content"
  140. android:layout_height="match_parent"
  141. android:layout_gravity="center"
  142. android:layout_weight="1"
  143. android:orientation="horizontal"
  144. android:gravity="center">
  145.  
  146. <Button
  147. android:id="@+id/plantList"
  148. android:layout_width="90px"
  149. android:layout_height="100px"
  150. android:background="@drawable/list" />
  151. </LinearLayout>
  152. </LinearLayout>
  153. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement