Currently there are two fragment : one for the area for adding image view, text view. The other is a list fragment
I would like to include both in one fragment , that means the area fragment is at the top of the list fragment , however, they are two class so how to include them , or I need to re-arrange the code to one class?
Also, how do I change the list fragment to fragment ?(Since setadapter and onclick event are not available in fragment class).Thanks.
code example : the List fragment part
public class SlidingMenuListFragment extends ListFragment {
protected List<SlidingMenuListItem> slidingMenuList;
private SlidingMenuBuilderBase slidingMenuBuilderBase;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// We set here a custom layout which uses holo light theme colors.
return inflater.inflate(R.layout.sliding_menu_holo_light_list, null);
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// We get a list from our specially created list data class.
slidingMenuList = SlidingMenuList.getSlidingMenu(getActivity());
if (slidingMenuList == null)
return;
// We pass our taken list to the adapter.
SlidingMenuListAdapter adapter = new SlidingMenuListAdapter(
getActivity(), R.layout.sliding_menu_holo_light_list_row, slidingMenuList);
setListAdapter(adapter);
}
// We could define item click actions here, but instead we want our builder
// to be responsible for that.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
l.setSelection(position);
SlidingMenuListItem item = slidingMenuList.get(position);
slidingMenuBuilderBase.onListItemClick(item);
}
// We can not provide a builder as an argument inside a fragment
// constructor, so that is why we have separate method for that.
public void setMenuBuilder(SlidingMenuBuilderBase slidingMenuBuilderBase) {
this.slidingMenuBuilderBase = slidingMenuBuilderBase;
}
Since Android 4.2, you can use Nested Fragments. And to older versions, you should use the Support Library