Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android谷歌地图膨胀异常:二进制XML文件行#13_Java_Android_Xml_Google Maps_Android Fragments - Fatal编程技术网

Java Android谷歌地图膨胀异常:二进制XML文件行#13

Java Android谷歌地图膨胀异常:二进制XML文件行#13,java,android,xml,google-maps,android-fragments,Java,Android,Xml,Google Maps,Android Fragments,在我的activity_main.XML文件中,我有三个主要部分, 1) 操作栏(工具栏)-其位于顶部, 2)框架-中间, 3) 底部栏(工具栏) 现在在FrameLayout中,我想根据底部工具栏中的按钮选择添加和替换片段。在我的第一个片段中,我有谷歌地图,在我的第二和第三个片段中,我有ListView。我还通过在替换/添加片段的同时添加这个来添加backbackback中的片段 ft.addToBackStack(null); 现在的问题是,每当我通过点击底部的按钮打开每个片段时,所有片段

在我的activity_main.XML文件中,我有三个主要部分, 1) 操作栏(工具栏)-其位于顶部, 2)框架-中间, 3) 底部栏(工具栏)

现在在FrameLayout中,我想根据底部工具栏中的按钮选择添加和替换片段。在我的第一个片段中,我有谷歌地图,在我的第二和第三个片段中,我有ListView。我还通过在替换/添加片段的同时添加这个来添加backbackback中的片段

ft.addToBackStack(null);
现在的问题是,每当我通过点击底部的按钮打开每个片段时,所有片段都完全正常工作。但是,如果我从第一个(谷歌地图)片段中打开第二个或第三个片段,并且如果我再次尝试通过单击“上一步”按钮返回到同一个谷歌地图片段,则会在Logcat中显示这些错误

Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f0e00d9, tag null, or parent id 0xffffffff wi
09-16 16:46:29.112    6985-6985/com.imnv.im026.goodmorning E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.imnv.im026.goodmorning, PID: 6985
android.view.InflateException: Binary XML file line #8: Error inflating class fragment
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
     ........................   com.imnv.im026.goodmorning.FragmentLocate.onCreateView(FragmentLocate.java:64)
我的地图片段xml文件是

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">

<fragment
    android:id="@+id/locateDriverMap"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<LinearLayout
    android:id="@+id/locateCallIconLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">

    <include
        android:id="@+id/includedCallIcon"
        layout="@layout/locate_frament_bottom_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>

我的任何地图片段类都是

public class FragmentLocate extends Fragment {

private PrefManager pref;
ur="example.com/---";
private GoogleMap mMap;
Activity mActivity;
private View view;
private String userId, driverId;
private static double latitude1, longitude1;

android.support.v4.app.FragmentManager fragmentManager;

GetDriverForCustomer getDriverId;

public FragmentLocate() {
}

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    this.mActivity = activity;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    view = inflater.inflate(R.layout.fragment_locate, container, false);

    getDriverId = new GetDriverForCustomer(getActivity());
    driverId = getDriverId.getDriverProfileDetails();

    pref = new PrefManager(getActivity());
    userId = pref.getKeyUserid();

    getDriverGeoLocation();
         mMap =   ((SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map))
            .getMap();


    mMap.setOnMyLocationChangeListener(myLocationChangeListener);
    return view;
}

@Override
public void onStart() {
    super.onStart();

}

private GoogleMap.OnMyLocationChangeListener myLocationChangeListener =  new GoogleMap.OnMyLocationChangeListener() {
    @Override
    public void onMyLocationChange(Location location) {
        LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());

        mMap.addMarker(new MarkerOptions().position(loc).icon(null).title("Your Location"));
        if (mMap != null) {
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(loc, 16.0f));
        }
    }
};

private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(latitude1, longitude1)).title("Driver Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.car_marker)));
    LatLng coordinate = new LatLng(latitude1, longitude1);
    CameraUpdate DriverLocation = CameraUpdateFactory
            .newLatLngZoom(coordinate, 12);
    mMap.setMyLocationEnabled(true);
    mMap.animateCamera(DriverLocation);

    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(coordinate)
            .zoom(17)
            .build();
    mMap.animateCamera(CameraUpdateFactory
            .newCameraPosition(cameraPosition));
}

/*@Override
public void onResume() {
    super.onResume();
    *//*setUpMapIfNeeded();
    if (mMap == null) {
        mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map))
                .getMap();
        if (mMap != null) {
            setUpMap();
        }
    }*//*
}*/

public void getDriverGeoLocation() {
    /*driverId = pref.getKeyDriverid();
    Log.d("driverId", driverId);*/

    String fullUrl = locateURL + driverId;
    Log.d("PrintFullURL", fullUrl);

    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            fullUrl, null, new Response.Listener<JSONObject>() {

        private String jsonResponse = "";

        @Override
        public void onResponse(JSONObject response) {

            Log.d("Activity Car Profile ", response.toString());

            try {
                JSONArray jcarArray = response.getJSONArray("getdriverlocation");

                for (int i = 0; i < jcarArray.length(); i++) {
                    JSONObject driverLocation = jcarArray.getJSONObject(i);

                    latitude1 = Double.parseDouble(driverLocation.getString("latitude"));
                    longitude1 = Double.parseDouble(driverLocation.getString("longitude"));
                    Log.e("latitude & longitude", latitude1 + " " + longitude1);
                }

                mMap.addMarker(new MarkerOptions().position(new LatLng(latitude1, longitude1)).title("Marker").icon(BitmapDescriptorFactory.fromResource(R.drawable.car_marker)));
                LatLng coordinate = new LatLng(latitude1, longitude1);
                CameraUpdate DriverLocation = CameraUpdateFactory
                        .newLatLngZoom(coordinate, 12);
                mMap.setMyLocationEnabled(true);
                mMap.animateCamera(DriverLocation);

                CameraPosition cameraPosition = new CameraPosition.Builder()
                        .target(coordinate)
                        .zoom(17)
                        .build();
                mMap.animateCamera(CameraUpdateFactory
                        .newCameraPosition(cameraPosition));


            } catch (JSONException e) {
                e.printStackTrace();
                Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_LONG).show();
            }


        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d("Activity Car Profile", "Error: " + error.toString());

        }
    });

    AppController.getInstance().addToRequestQueue(jsonObjReq);
}
}
公共类碎片定位扩展碎片{
私人pref;
ur=“example.com/--”;
私有谷歌地图;
活动能力;
私人视野;
私有字符串userId,driverId;
专用静态双纬度1,纵向1;
android.support.v4.app.FragmentManager FragmentManager;
GetDriverForCustomer getDriverId;
公共碎片定位(){
}
@凌驾
公共事务主任(活动){
超级转速计(活动);
这个。活动=活动;
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
视图=充气机。充气(R.layout.fragment\u locate,container,false);
getDriverId=新的GetDriverForCustomer(getActivity());
driverId=getDriverId.getDriverProfileDetails();
pref=新的PrefManager(getActivity());
userId=pref.getKeyUserid();
getDriverGeoLocation();
mMap=((SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map))
.getMap();
mMap.setOnMyLocationChangeListener(myLocationChangeListener);
返回视图;
}
@凌驾
public void onStart(){
super.onStart();
}
私有GoogleMap.OnMyLocationChangeListener myLocationChangeListener=新建GoogleMap.OnMyLocationChangeListener(){
@凌驾
公共void onMyLocationChange(位置){
LatLng loc=新LatLng(location.getLatitude(),location.getLongitude());
mMap.addMarker(新的MarkerOptions().position(loc).icon(null).title(“您的位置”);
如果(mMap!=null){
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(loc,16.0f));
}
}
};
私有void setUpMap(){
mMap.addMarker(新MarkerOptions().position(新LatLng(latitude1,longitude1)).title(“驱动程序位置”).icon(BitmapDescriptorFactory.fromResource(R.drawable.car_marker));
车床坐标=新车床(纬度1,纵向1);
CameraUpdate DriverLocation=CameraUpdateFactory
.newLatLngZoom(坐标,12);
mMap.setMyLocationEnabled(真);
mMap.animateCamera(驾驶员位置);
CameraPosition CameraPosition=新建CameraPosition.Builder()
.目标(坐标)
.zoom(17)
.build();
mMap.animateCamera(相机更新工厂
.newCameraPosition(cameraPosition));
}
/*@凌驾
恢复时公开作废(){
super.onResume();
*//*setupmapifneed();
如果(mMap==null){
mMap=((SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map))
.getMap();
如果(mMap!=null){
setUpMap();
}
}*//*
}*/
public void getDriverGeoLocation(){
/*driverId=pref.getKeyDriverid();
日志d(“driverId”,driverId)*/
字符串fullUrl=locateURL+driverId;
Log.d(“PrintFullURL”,fullUrl);
JsonObjectRequest JSONObjectReq=新的JsonObjectRequest(Request.Method.GET,
fullUrl,null,新响应。侦听器(){
私有字符串jsonResponse=“”;
@凌驾
公共void onResponse(JSONObject响应){
Log.d(“活动车辆配置文件”,response.toString());
试一试{
JSONArray jcarArray=response.getJSONArray(“getdriverlocation”);
for(int i=0;i
我的文件是

<?xml version="1.0" encoding="utf-8"?>


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:name=".app.AppController"
    android:allowBackup="true"
    android:icon="@mipmap/gm_icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:uiOptions="splitActionBarWhenNarrow">
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_key" />
    <meta-data
        android:name="android.support.UI_OPTIONS"
        android:value="splitActionBarWhenNarrow" />

    <activity
        android:name=".ViewPagerScreen"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Login"
        android:label="string/login_bt" />
    <activity
        android:name=".DriverShiftActivity"
        android:label="@string/title_activity_driver_shift"
        android:uiOptions="splitActionBarWhenNarrow">
        <meta-data
            android:name="android.support.UI_OPTIONS"
            android:value="splitActionBarWhenNarrow" />
    </activity>
    <activity
        android:name=".BaseMenuActivity"
        android:label="@string/title_activity_base_menu"
        android:uiOptions="splitActionBarWhenNarrow">
        <meta-data
            android:name="android.support.UI_OPTIONS"
            android:value="splitActionBarWhenNarrow" />
    </activity>
    <activity
        android:name=".SignUp"
        android:label="@string/title_activity_sign_up" />
    <activity
        android:name=".DiaglogBoxShiftDriver"
        android:label="@string/title_activity_diaglog_box_shift_driver"
        android:theme="@android:style/Theme.Dialog" />
    <activity
        android:name=".FuelDetails"
        android:label="@string/title_activity_fuel_details" />
    <activity
        android:name=".MyProfile"
        android:label="@string/title_activity_my_profile" />
    <activity
        android:name=".CarProfile"
        android:label="@string/title_activity_car_profile" />
    <activity
        android:name=".CustomerProfile"
        android:label="@string/title_activity_customer_profile" />
    <activity
        android:name=".ChatTimeLine"
        android:label="@string/title_activity_chat_time_line" />
    <activity
        android:name=".CustomerActivity"
        android:label="@string/title_activity_customer"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerEnquiryActivity"
        android:label="@string/title_activity_customer_enquiry"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerEmergencyActivity"
        android:label="@string/title_activity_customer_emergency"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerMyProfile"
        android:label="@string/title_activity_customer_my_profile"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerDriverProfile"
        android:label="@string/title_activity_customer_driver_profile"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerPlaceInDetail"
        android:label="@string/title_activity_customer_place_in_detail"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerSelectedCategory"
        android:label="@string/title_activity_customer_selected_category"
        android:theme="@style/MyMaterialTheme" />
    <activity
        android:name=".CustomerChangePassword"
        android:label="@string/title_activity_customer_forget_password"
        android:theme="@style/MyMaterialTheme" />
</application>

</manifest>
 if (view != null) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null)
        parent.removeView(view);
}
try {
    view = inflater.inflate(R.layout.map, container, false);
} catch (InflateException e) {
    /* map is already there, just return view as it is */
}


return view;