@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.DrawerTheme);
    // setTitle(mTitleRes);
    // set the Behind View
    setBehindContentView(R.layout.menu_scrollview);

    final ActionBar actionbar = getActionBar();
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // customize the SlidingMenu
    sm = getSlidingMenu();
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    sm.setMode(SlidingMenu.LEFT);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setFadeEnabled(true);
    sm.setFadeEnabled(true);
    sm.setFadeDegree(0.95f);
    // sm.setSecondaryMenu(R.layout.sidemenumap);
    // sm.setSecondaryShadowDrawable(R.drawable.shadowright);
    sm.setBackgroundColor(0x000000000);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getSlidingMenu()
        .setOnOpenedListener(
            new OnOpenedListener() {
              public void onOpened() {
                getSlidingMenu().invalidate();
                // mMap.setMyLocationEnabled(true);
              }
            });

    findViewById(R.id.item1).setOnClickListener(this);
    findViewById(R.id.item2).setOnClickListener(this);
    findViewById(R.id.item3).setOnClickListener(this);
    findViewById(R.id.item4).setOnClickListener(this);
    findViewById(R.id.item5).setOnClickListener(this);
    findViewById(R.id.item9).setOnClickListener(this);
    findViewById(R.id.item10).setOnClickListener(this);
    findViewById(R.id.item11).setOnClickListener(this);
    findViewById(R.id.item12).setOnClickListener(this);
    findViewById(R.id.item13).setOnClickListener(this);
  }
Beispiel #2
0
  /**
   * Instantiates a new SlidingMenu.
   *
   * @param context the associated Context
   * @param attrs the attrs
   * @param defStyle the def style
   */
  public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    LayoutParams behindParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mViewBehind = new CustomViewBehind(context);
    addView(mViewBehind, behindParams);
    LayoutParams aboveParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mViewAbove = new CustomViewAbove(context);
    addView(mViewAbove, aboveParams);
    // register the CustomViewBehind with the CustomViewAbove
    mViewAbove.setCustomViewBehind(mViewBehind);
    mViewBehind.setCustomViewAbove(mViewAbove);
    mViewAbove.setOnPageChangeListener(
        new OnPageChangeListener() {
          public static final int POSITION_OPEN = 0;
          public static final int POSITION_CLOSE = 1;

          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          public void onPageSelected(int position) {
            if (position == POSITION_OPEN && mOpenListener != null) {
              mOpenListener.onOpen();
            } else if (position == POSITION_CLOSE && mCloseListener != null) {
              mCloseListener.onClose();
            }
          }
        });

    // now style everything!
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingMenu);
    // set the above and behind views if defined in xml
    int mode = ta.getInt(R.styleable.SlidingMenu_mode, LEFT);
    setMode(mode);
    int viewAbove = ta.getResourceId(R.styleable.SlidingMenu_viewAbove, -1);
    if (viewAbove != -1) {
      setContent(viewAbove);
    } else {
      setContent(new FrameLayout(context));
    }
    int viewBehind = ta.getResourceId(R.styleable.SlidingMenu_viewBehind, -1);
    if (viewBehind != -1) {
      setMenu(viewBehind);
    } else {
      setMenu(new FrameLayout(context));
    }
    int touchModeAbove = ta.getInt(R.styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN);
    setTouchModeAbove(touchModeAbove);
    int touchModeBehind = ta.getInt(R.styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN);
    setTouchModeBehind(touchModeBehind);

    int offsetBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindOffset, -1);
    int widthBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindWidth, -1);
    if (offsetBehind != -1 && widthBehind != -1)
      throw new IllegalStateException(
          "Cannot set both behindOffset and behindWidth for a SlidingMenu");
    else if (offsetBehind != -1) setBehindOffset(offsetBehind);
    else if (widthBehind != -1) setBehindWidth(widthBehind);
    else setBehindOffset(0);
    float scrollOffsetBehind = ta.getFloat(R.styleable.SlidingMenu_behindScrollScale, 0.33f);
    setBehindScrollScale(scrollOffsetBehind);
    int shadowRes = ta.getResourceId(R.styleable.SlidingMenu_shadowDrawable, -1);
    if (shadowRes != -1) {
      setShadowDrawable(shadowRes);
    }
    int shadowWidth = (int) ta.getDimension(R.styleable.SlidingMenu_shadowWidth, 0);
    setShadowWidth(shadowWidth);
    boolean fadeEnabled = ta.getBoolean(R.styleable.SlidingMenu_fadeEnabled, true);
    setFadeEnabled(fadeEnabled);
    float fadeDeg = ta.getFloat(R.styleable.SlidingMenu_fadeDegree, 0.33f);
    setFadeDegree(fadeDeg);
    boolean selectorEnabled = ta.getBoolean(R.styleable.SlidingMenu_selectorEnabled, false);
    setSelectorEnabled(selectorEnabled);
    int selectorRes = ta.getResourceId(R.styleable.SlidingMenu_selectorDrawable, -1);
    if (selectorRes != -1) setSelectorDrawable(selectorRes);
    ta.recycle();
  }
Beispiel #3
0
  /** 初始化控件 */
  public void initWidget() {
    slidingMenu = new SlidingMenu(this);
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slidingMenu.setBehindScrollScale(0);
    slidingMenu.setFadeDegree(1f);
    slidingMenu.setFadeEnabled(true);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);

    slidingMenu.setBehindOffset(getScreenWidth() / 2);
    slidingMenu.setMenu(R.layout.sidebar_layout);

    editTopLayout = (RelativeLayout) findViewById(R.id.edit_top_title);
    searchTitle = (RelativeLayout) findViewById(R.id.main_top_search);
    bottomLayout = (LinearLayout) findViewById(R.id.main_bottom);
    seeAllButton = (ImageButton) findViewById(R.id.seeallbtn);
    addNoteButton = (ImageButton) findViewById(R.id.addnotebtn);
    addTypeButton = (ImageButton) findViewById(R.id.addtype_btn);
    deleteButton = (ImageButton) findViewById(R.id.delete_btn_main);
    shareButton = (ImageButton) findViewById(R.id.share_btn_main);
    moveButton = (ImageButton) findViewById(R.id.move_btn_main);
    lockedButton = (ImageButton) findViewById(R.id.locked_btn_main);
    unlockedButton = (ImageButton) findViewById(R.id.unlocked_btn_main);
    showTypeView = (TextView) findViewById(R.id.showtype);
    showSelectView = (TextView) findViewById(R.id.showselect);
    showNowDateView = (TextView) findViewById(R.id.nowdate_tv);
    typeGroup = (RadioGroup) findViewById(R.id.typegroup);
    noteListView = (ListView) findViewById(R.id.notelist);
    showEmptyView = (LinearLayout) findViewById(R.id.showempty_view);
    showSearchButton = (Button) findViewById(R.id.searchbtn_sidebar);
    calendarButton = (Button) findViewById(R.id.calendarbtn_sidebar);
    albumButton = (Button) findViewById(R.id.albumbtn_sidebar);
    passwdButton = (Button) findViewById(R.id.passwdbtn_sidebar);
    feedbackButton = (Button) findViewById(R.id.feedbackbtn_sidebar);
    shareAppButton = (Button) findViewById(R.id.shareappbtn_sidebar);
    aboutButton = (Button) findViewById(R.id.aboutbtn_sidebar);
    startSearchButton = (ImageButton) findViewById(R.id.startsearch_btn);
    voiceSearchButton = (ImageButton) findViewById(R.id.voice_search_btn);
    searchEditText = (EditText) findViewById(R.id.edittext_search);
    changeOrderButton = (ImageButton) findViewById(R.id.changebtn);

    seeAllButton.setOnClickListener(this);
    addNoteButton.setOnClickListener(this);
    addTypeButton.setOnClickListener(this);
    deleteButton.setOnClickListener(this);
    shareButton.setOnClickListener(this);
    moveButton.setOnClickListener(this);
    lockedButton.setOnClickListener(this);
    unlockedButton.setOnClickListener(this);
    showSearchButton.setOnClickListener(this);
    startSearchButton.setOnClickListener(this);
    calendarButton.setOnClickListener(this);
    albumButton.setOnClickListener(this);
    passwdButton.setOnClickListener(this);
    feedbackButton.setOnClickListener(this);
    shareAppButton.setOnClickListener(this);
    aboutButton.setOnClickListener(this);
    voiceSearchButton.setOnClickListener(this);
    changeOrderButton.setOnClickListener(this);
    noteListView.setOnItemClickListener(this);
    noteListView.setOnItemLongClickListener(this);

    noteTypeDao = new NoteTypeDao(MainActivity.this);

    // 初始化语音识别器
    initVoiceRecognizer();

    // 获取所有分类
    typeList = noteTypeDao.getAllTyep();
    // 动态加载radiobutton
    for (int i = 0; i < typeList.size(); i++) {
      AddRadioButton(typeList.get(i).get("type").toString());
    }

    // 初始化所有的记事本并显示
    noteDetailDao = new NoteDetailDao(MainActivity.this);

    // 显示当前时间
    showNowDate();

    // 创建需要用到的文件夹
    createDir();
  }