Reputation: 668
I am trying to get a hold of a fragment that is within a LinearLayout I have created:
Edit: This is within a class that extends ArrayAdapter<G>
LinearLayout newView = new LinearLayout(getContext());
String inflater = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater li;
li = (LayoutInflater) getContext().getSystemService(inflater);
li.inflate(resource, newView, true);
Within the layout is a fragment called TableRowView:
Edit: I corrected the XML syntax
<fragment android:name ="mypackage.TableRowView"
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="match_parent" />
How do I get a hold of newView
's fragment?
Thanks in advance, --David
Upvotes: 1
Views: 2630
Reputation: 1006914
I am trying to get a hold of a fragment that is within a LinearLayout I have created
The fragment is not within a LinearLayout
. A fragment is not a View
and does not reside inside a ViewGroup
. The View
created by the fragment in onCreateView()
will reside in a ViewGroup
.
I am trying to get a hold of a fragment that is within a LinearLayout I have created
Try calling findFragmentById()
on the FragmentManager
, provided that you set an ID on newView
before the inflation operation.
Upvotes: 2