我有一个包含列表视图的片段活动。单击 ListView 的项目时,我想加载一个片段并关闭片段活动。
我尝试如下实现,但FrameLayout
在我尝试加载的位置出现 id错误Fragment
。
日志猫:
09-03 16:49:57.321: E/AndroidRuntime(1740): FATAL EXCEPTION: main 09-03 16:49:57.321: E/AndroidRuntime(1740): java.lang.IllegalArgumentException: No view found for id 0x7f0a0045 (com.zeal.peekaboo:id/fragmentswitcherframe) for fragment OtherProfileFragment{4a31cb00 #0 id=0x7f0a0045} 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.os.Handler.handleCallback(Handler.java:587) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.os.Handler.dispatchMessage(Handler.java:92) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.os.Looper.loop(Looper.java:123) 09-03 16:49:57.321: E/AndroidRuntime(1740): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-03 16:49:57.321: E/AndroidRuntime(1740): at java.lang.reflect.Method.invokeNative(Native Method) 09-03 16:49:57.321: E/AndroidRuntime(1740): at java.lang.reflect.Method.invoke(Method.java:521) 09-03 16:49:57.321: E/AndroidRuntime(1740): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-03 16:49:57.321: E/AndroidRuntime(1740): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-03 16:49:57.321: E/AndroidRuntime(1740): at dalvik.system.NativeStart.main(Native Method)
Listview ItemClick
m_lvList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adptr, View view, int pos, long id) { m_slistItemId = String.valueOf(m_lookArryList.get(pos) .getM_userId()); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment llf = new OtherProfileFragment(); ft.replace(R.id.fragmentswitcherframe, llf); ft.commit(); finish(); } });
请为此指导我。我无法理解出了什么问题?
任何帮助将不胜感激。
谢谢。