Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

java - Fragment Transaction - No view found for id 0x7f090022

I'm trying to replace a Fragment when I click on a item List, the thing is that I've got the same code for 5 differents fragments and it works on all, only on this Fragment says :

java.lang.IllegalArgumentException: No view found for id 0x7f090022 (info.androidhive.slidingmenu:id/frame_container) for fragment DetallProductePerTipus{3899b306 #1 id=0x7f090022}

It says the frame_container is not found... This is how I do the replace :

    Bundle bundle = new Bundle();
    android.support.v4.app.Fragment fragment = new DetallProductePerTipus();
    bundle.putString("titol", item.title);

    fragment.setArguments(bundle);

    getFragmentManager().beginTransaction()

            .replace(R.id.frame_container, fragment).commit();

I had problems with transaction with Fragments v4 and not v4, and then I tried also this :

   Bundle bundle = new Bundle();
   Fragment fragment = new DetallProductePerTipus();
    bundle.putString("titol", item.title);

    fragment.setArguments(bundle);

    getFragmentManager().beginTransaction()

            .replace(R.id.frame_container, fragment).commit();

but it still doesn't work...

What I'm doing wrong?

On the same Fragment I've got this code that makes a replace of a Fragment, I want the same but adding the Bundle.

android.support.v4.app.FragmentManager fm = getActivity().getSupportFragmentManager();
android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.frame_container, new ListaProductosFragment());
ft.commit();
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally solved my problem doing this :

Bundle bundle = new Bundle();
bundle.putString("titol", item.title);
android.support.v4.app.FragmentManager fm = getActivity().getSupportFragmentManager();
Fragment fragment = new DetallProducteOffer();
fragment.setArguments(bundle);
fm.beginTransaction()
.replace(R.id.frame_container, fragment).commit();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...