Пример #1
0
 /** 提供给fragment设置menudrawer触摸模式 */
 public void setMenuDrawerEnable(boolean enable) {
   if (enable) {
     mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
   } else {
     mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_BEZEL);
   }
 }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    pagerAdapter = new PagerAdapter(getChildFragmentManager());
    pager.setAdapter(pagerAdapter);
    tabStrip.setViewPager(pager);
    tabStrip.setOnPageChangeListener(new OnPageScrollListener());

    pullRefreshListViewMap = new HashMap<Integer, PullRefreshListView>(3);
    memberAdapterMap = new HashMap<Integer, MemberAdapter>(3);

    // 设置右侧触摸监听
    sideBar.setOnTouchingLetterChangedListener(
        new SideBar.OnTouchingLetterChangedListener() {

          @Override
          public void onTouchingLetterChanged(String s) {
            // 该字母首次出现的位置
            int position =
                memberAdapterMap.get(pager.getCurrentItem()).getPositionForSection(s.charAt(0));
            if (position != -1) {
              pullRefreshListViewMap.get(pager.getCurrentItem()).setSelection(position);
            }
          }
        });
    menuDrawer = activity.getMenuDrawer();
    if (menuDrawer != null) {
      menuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
    }
  }
  @Override
  protected void onCreate(Bundle inState) {
    super.onCreate(inState);

    mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.TOP);
    mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
    mMenuDrawer.setContentView(R.layout.activity_topmenu);
    mMenuDrawer.setMenuView(R.layout.menu_top);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
      getActionBar().setDisplayHomeAsUpEnabled(true);

    mContentTextView = (TextView) findViewById(R.id.contentText);
    findViewById(R.id.item1).setOnClickListener(this);
    findViewById(R.id.item2).setOnClickListener(this);
  }
Пример #4
0
 /** 侧滑菜单初始化 */
 public void initMenuview() {
   View settingview = getLayoutInflater().inflate(R.layout.main_setting, null);
   mDrawer.setMenuView(settingview);
   // menudrawer的侧滑界面的listview
   mListView = (ListView) settingview.findViewById(R.id.listView1);
   String[] mTitle = getResources().getStringArray(R.array.menu_str);
   int images[] =
       new int[] {
         R.drawable.ic_menu_login,
         R.drawable.ic_menu_home,
         R.drawable.ic_menu_group,
         R.drawable.ic_menu_public,
         R.drawable.ic_menu_setting
       };
   /** 用户登陆判断* */
   //		SharedPreferences sp = getPreferences(MODE_PRIVATE);
   SharedPreferences sp = getSharedPreferences("userinfo", 0);
   // 自动登陆
   autologin = sp.getBoolean("autologin", false);
   if (autologin) {
     username = sp.getString("username", "cpoopc");
   } else {
     sp.edit().putString("username", "").commit();
   }
   // 用户名
   if (username != null && !"".equals(username)) {
     mTitle[0] = username;
   }
   settingAdapter = new SettingAdapter(this, mTitle, images);
   mListView.setAdapter(settingAdapter);
   mListView.setOnItemClickListener(this);
   //		mDrawer.setDropShadowColor(Color.BLUE);
   mDrawer.setSlideDrawable(R.drawable.ic_setting);
   mDrawer.setDrawerIndicatorEnabled(true);
   mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
   mDrawer.setMenuSize(250);
   // 第一次使用提示可以侧滑
   boolean firstUse = sp.getBoolean("firstUse", true);
   if (firstUse) {
     mDrawer.peekDrawer(1000, 0);
     Editor edit = sp.edit();
     edit.putBoolean("firstUse", false);
     edit.commit();
   }
 }