2

ViewPager在包含自定义布局的应用程序中实现了 in Fragment。现在在 ViewPager 的自定义布局中有一个我想用其他片段替换当前片段的TextViewonClick 。TextView让我们说 Fragment2。

我已经尝试替换,但它给出了FrameLayout我想要加载片段的资源 id 的错误。我已经检查了 SO 中的相关解决方案,但没有一个对我有帮助。

请任何人都可以指导我解决这个错误。这将非常感激和赞赏。

日志猫:

11-13 11:17:54.480: E/AndroidRuntime(3982): FATAL EXCEPTION: main
11-13 11:17:54.480: E/AndroidRuntime(3982): java.lang.IllegalArgumentException: No view found for id 0x7f0600cc for fragment OtherProfileFragment{40ceba28 #4 id=0x7f0600cc}
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.os.Handler.handleCallback(Handler.java:725)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.os.Looper.loop(Looper.java:137)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at android.app.ActivityThread.main(ActivityThread.java:5041)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at java.lang.reflect.Method.invokeNative(Native Method)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at java.lang.reflect.Method.invoke(Method.java:511)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-13 11:17:54.480: E/AndroidRuntime(3982):     at dalvik.system.NativeStart.main(Native Method)

这是我的代码,TextView我正在尝试加载片段。

    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_feed_detail, container,
            false);
    m_tvProfileName = (TextView) v.findViewById(R.id.afd_tvProfileName);
    m_tvProfileName.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            FragmentManager m_mange = m_context.getSupportFragmentManager();
            FragmentTransaction fm = m_mange.beginTransaction();
            Fragment llf = new OtherFragment();
            Bundle m_bundle = new Bundle();
            m_bundle.putInt("Id", Id);
            llf.setArguments(m_bundle);
            fm.addToBackStack("Other");
            fm.replace(R.id.fragmentswitcherframe, llf); //This line throwing error
            fm.commit();
            getActivity().finish();

        }
    });

    return v;
}
4

0 回答 0