I've got a listfragment inside a fragment. I want to get the list inside the parent fragment, in the onActivityCreated but i can't figure out how to do so. I want to do that because the list is a custom listview with 2 textview and a checkbox and i need to see which items are checked.
My parent fragment :
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getChildFragmentManager()
.beginTransaction()
.replace(R.id.list_topgain_frame, new ListFragmentTopGain())
.commit();
return inflater.inflate(R.layout.parier3, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
btnGainValider = (Button) getActivity().findViewById(R.id.btnGainValider);
btnGainValider.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
The frame layout that i replace with the ListFragment :
<FrameLayout
android:id="@+id/list_choixamis_frame"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_below="@id/txvChoixAmis"
android:layout_marginBottom="20dp" />
I found a little trick cause i still can't find how to get the list in the parent fragment..
Anyway, if someone else had this issue, I bypassed by using a listener in my customAdapter. then i pass the information : customAdapter -> ListFragment -> ParentFragment.