错误
E / Android运行时:致命异常:主要 流程:com.pockethcm.greytrix.test,PID:6566 android.view.InflateException:二进制XML文件第29行:二进制XML文件第29行:夸大类片段的错误 原因:android.view.InflateException:二进制XML文件行#29:错误夸大了类片段 造成原因:java.lang.IllegalArgumentException:二进制XML文件第29行:重复的ID 0x7f09012d,标记为null或父ID 0xffffffff与com.google.android.gms.maps.SupportMapFragment的另一个片段 在android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3680) 在android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111) 在android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:338) 在android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39) 在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67) 在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780) 在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 在android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 在android.view.LayoutInflater.inflate(LayoutInflater.java:515) 在android.view.LayoutInflater.inflate(LayoutInflater.java:423) 在android.view.LayoutInflater.inflate(LayoutInflater.java:374) 在com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:420) 在android.app.Dialog.setContentView(Dialog.java:557) 在com.pockethcm.greytrix.test.Fragments.DashboardFragment.openPunchDetailDialog(DashboardFragment.kt:1183) 在com.pockethcm.greytrix.test.Fragments.DashboardFragment $ sendLocationData $ 1.onSuccess(DashboardFragment.kt:767) 在com.pockethcm.greytrix.test.Fragments.DashboardFragment $ sendLocationData $ 1.onSuccess(DashboardFragment.kt:102) 位于com.google.android.gms.tasks.zzj.run(未知来源:27) 在android.os.Handler.handleCallback(Handler.java:873) 在android.os.Handler.dispatchMessage(Handler.java:99) 在android.os.Looper.loop(Looper.java:193) 在android.app.ActivityThread.main(ActivityThread.java:6669) 在java.lang.reflect.Method.invoke(本机方法) 在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
片段代码
var mapFragment = activity.supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
if(mapFragment != null){
mapFragment!!.getMapAsync(OnMapReadyCallback {
googleMap = it
val location1 = LatLng(13.03,77.60)
val location2 = LatLng(13.53,77.67)
googleMap.addMarker(MarkerOptions().position(location1).title("First Location"))
googleMap.addMarker(MarkerOptions().position(location2).title("Second Location"))
val center = CameraUpdateFactory.newLatLng(location1)
val zoom = CameraUpdateFactory.zoomTo(15f)
val markerPoints = LatLngBounds(
location1, location2)
googleMap.setOnMapLoadedCallback(GoogleMap.OnMapLoadedCallback {
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(markerPoints,30))
})
})
}
punchdetailLayout
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/view_layout"
android:orientation="vertical"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Address"
android:layout_weight="0.5"
android:textColor="#000000"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/address"
android:textColor="#000000"
android:layout_weight="0.5"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Locality"
android:layout_weight="0.5"
android:textColor="#000000"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/locality"
android:textColor="#000000"
android:layout_weight="0.5"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Time"
android:layout_weight="0.5"
android:textColor="#000000"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/time"
android:textColor="#000000"
android:layout_weight="0.5"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ok"
android:text="OK">
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Records Found!"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:visibility="gone"
android:id="@+id/no_rec"
/>
</android.support.v7.widget.CardView>