コード例 #1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    slidingMenu = new SlidingMenu(MonthActivity.this);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
      setContentView(R.layout.main);
      slidingMenu.setBehindOffset((int) (getResources().getDisplayMetrics().widthPixels * 0.15));
    } else {
      setContentView(R.layout.main);
      slidingMenu.setBehindOffset((int) (getResources().getDisplayMetrics().widthPixels * 0.5));
      Fragment newFragment = new DetailDayFragment();
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.add(R.id.day_or_pair_frame, newFragment).commit();
    }

    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
    slidingMenu.setMenu(R.layout.sliding_menu);

    slidingMenu
        .findViewById(R.id.sliding_menu_lessons)
        .setOnClickListener(new LessonsItemOnClick());
    slidingMenu
        .findViewById(R.id.sliding_menu_teachers)
        .setOnClickListener(new TeachersItemOnClick());

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    new TestData().addingTo(AppDB.getInstance(this));
  }
コード例 #2
0
 /**
  * Finds a view that was identified by the id attribute from the XML that was processed in
  * onCreate(Bundle).
  *
  * @param id the resource id of the desired view
  * @return The view if found or null otherwise.
  */
 public View findViewById(int id) {
   View v;
   if (mSlidingMenu != null) {
     v = mSlidingMenu.findViewById(id);
     if (v != null) return v;
   }
   return null;
 }