coder_For_Life22 coder_For_Life22 - 1 year ago 972
Android Question

Android Fragment no view found for ID?

I have a fragment I am trying to add into a view.

FragmentManager fragMgr=getSupportFragmentManager();
feed_parser_activity content = (feed_parser_activity)fragMgr
FragmentTransaction xaction=fragMgr.beginTransaction();

if (content == null || content.isRemoving()) {
content=new feed_parser_activity(item.getLink().toString());
.add(, content)
Log.e("Abstract", "DONE");

When this code is executed I get the following error in debug..

java.lang.IllegalArgumentException: No view found for id 0x7f080011
for fragment feed_parser_activity{41882f50 #2 id=0x7f080011}

is a Fragment that is set to Fragment layout in xml.

I am using a FragmentActivity to host the Fragment Layout holding the

Am I coding this correctly above?

Answer Source

I was having this problem too, until I realized that I had specified the wrong layout in setContentView() of the onCreate() method of the FragmentActivity.

The id passed into FragmentTransaction.add(), in your case, must be a child of the layout specified in setContentView().

You didn't show us your onCreate() method, so perhaps this is the same problem.