Created
February 8, 2014 02:46
-
-
Save Yosuke-Kawakami/8875912 to your computer and use it in GitHub Desktop.
リスト選択時などの際、既に fragment があるよ的なエラーを吐かれてしまい、onCreateView 時に死んでしまう動作の対策。原始的だけどね ;-P
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
02-08 11:31:26.289: E/AndroidRuntime(9011): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850) | |
02-08 11:31:26.289: E/AndroidRuntime(9011): at dalvik.system.NativeStart.main(Native Method) | |
02-08 11:31:26.289: E/AndroidRuntime(9011): Caused by: java.lang.IllegalArgumentException: Binary XML file line #7: Duplicate id 0x7f050007, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment | |
02-08 11:31:26.289: E/AndroidRuntime(9011): at android.app.Activity.onCreateView(Activity.java:4783) | |
02-08 11:31:26.289: E/AndroidRuntime(9011): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onNavigationItemSelected(int position, long id) { | |
/* 作る時に重複しているのなら、生成する際に潰してしまおうという | |
* 下衆な対策(replace は仕事してんの?) | |
*/ | |
MapFragment tmp = (MapFragment) getFragmentManager().findFragmentById(R.id.map); | |
if (tmp != null) getFragmentManager().beginTransaction().remove(tmp).commit(); | |
getFragmentManager().beginTransaction().replace(R.id.f_detail, new MainFragment()).commit(); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment