我正在开发应用程序,保存进入和退出位置的位置。 并在对话框中打开地图。 我第一次点击打开对话框并查看位置,但是当我单击后退按钮或关闭(dialMap.dismiss();)并尝试再次单击打开对话框时我崩溃了! 在这里我的代码:
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错误:
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
我需要做什么?
答案 0 :(得分:0)
从logcat中看来,二进制文件中存在问题
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说你有两个同名的id?
第92行也是如此
at android.os.Handler.dispatchMessage(Handler.java:92)
和第137行?
at android.os.Looper.loop(Looper.java:137)