2013-11-26 54 views
0

enter image description here如何在android中的滑動菜單中添加橫幅區域?

我正在使用滑動菜單庫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; 
    } 

}

回答

0

導航抽屜的各實施有它自己的錯綜複雜,然而其中大多數允許你膨脹整個佈局,這意味着你可以使用線性佈局作爲父項,幷包括你的列表片段(或任何你想使用的)。我沒有閱讀到提供的庫,但我會建議看看谷歌實施navigation drawer

作爲說明:實際上我沒有嘗試過使用Google實現,當我實現一個導航抽屜時,它是在將它添加到支持庫之前,因此我創建了自己的抽屜。