在第二次点击对话框崩溃打开谷歌地图 [英] Open google maps on Dialog crashes at the second click

查看:177
本文介绍了在第二次点击对话框崩溃打开谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展与保存的进入和退出场所位置的应用程序。
并且地图在对话框打开。
每一个事情在第一时间即时做工精细点击打开对话框,看到的位置,但是当我点击后退按钮或关闭(dialMap.dismiss();),并尝试再次单击打开对话框i'ts崩溃!
我在这里的code:

I'm develop app with save the location of enter and exit places. and the map open in a Dialog . every things work fine at the first time im click to open the dialog and see the location, but when i click back button or close (dialMap.dismiss();) and try to click again to open the dialog i'ts crash! here my code:

public void openMap(double lat,double lng,double lat2,double lng2) throws IOException{

            final Dialog dialMap = new Dialog(this);
        dialMap.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialMap.setContentView(R.layout.dialog_map);
        Button btnExit = (Button) dialMap.findViewById(R.id.dialog_map_close);
        if(map==null){
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

        LatLng latLng = new LatLng(lat, lng);

        map.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        map.animateCamera(CameraUpdateFactory.zoomTo(15));

        map.addMarker(new MarkerOptions().position(new LatLng(lat, lng)).title("Enter"));
        map.addMarker(new MarkerOptions().position(new LatLng(lat2, lng2)).title("Exit"));
}
        dialMap.show();

        btnExit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialMap.dismiss();          

            }
        });

    }

logcat的错误:

logcat error:

05-19 16:23:39.936: E/AndroidRuntime(11365): FATAL EXCEPTION: main
05-19 16:23:39.936: E/AndroidRuntime(11365): android.view.InflateException: Binary XML file line #6: Error inflating class fragment
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.app.Dialog.setContentView(Dialog.java:478)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at com.bibas.workclock.ListOfHours.openMap(ListOfHours.java:3741)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at com.bibas.workclock.ListOfHours$20.onClick(ListOfHours.java:2571)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.View.performClick(View.java:4475)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.View$PerformClick.run(View.java:18786)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.os.Handler.handleCallback(Handler.java:730)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.os.Looper.loop(Looper.java:137)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.app.ActivityThread.main(ActivityThread.java:5419)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at java.lang.reflect.Method.invokeNative(Native Method)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at java.lang.reflect.Method.invoke(Method.java:525)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at dalvik.system.NativeStart.main(Native Method)
05-19 16:23:39.936: E/AndroidRuntime(11365): Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Duplicate id 0x7f060082, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.app.Activity.onCreateView(Activity.java:4971)
05-19 16:23:39.936: E/AndroidRuntime(11365):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
05-19 16:23:39.936: E/AndroidRuntime(11365):    ... 19 more

我需要什么?

推荐答案

从logcat的 - 它会出现有问题的中的二进制

From the logcat - it would appear that there are issues in your binary

Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Duplicate id 0x7f060082, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment

logcat的是说,你有2个ID的名称相同?

Logcat is saying that you have 2 id's with the same name?

还有什么是在线92

at android.os.Handler.dispatchMessage(Handler.java:92)

和137线?

at android.os.Looper.loop(Looper.java:137)

这篇关于在第二次点击对话框崩溃打开谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆