0
我正在使用滑動菜單庫https://github.com/jfeinstein10/SlidingMenu。
從一個工作示例:https://github.com/baruckis/Android-SlidingMenuImplementation它使用左側菜單中的列表片段。問題是,我想在列表頂部添加一個橫幅區域,有什麼方法可以實現? (如他們有搜索框和用戶信息在列表頂部的臉書)
我嘗試使用列表片段中的添加標題視圖,但我更喜歡該區域不可滑動並修復在頂部。由於
下面的代碼是列表片段類,其中R.layout.sliding_menu_holo_light_list是一個列表視圖,這樣看來我不能自定義它
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;
}
}