Saturday, May 02, 2015

Android Sliding Menu Configuration

super.onCreate(savedInstanceState);

new DataBaseHelper(MainActivity.this);


TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Light.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf

getSlidingMenu().setMode(SlidingMenu.LEFT);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

setBehindContentView(R.layout.frame_left_menu);

getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frame_leftmenu_layout, new left_menu())
.commit();

setContentView(R.layout.frame_content);

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
mDeviceWidth = dm.widthPixels;
mDeviceHeight = dm.heightPixels;

if(MainActivity.list_students.isEmpty() || obj_student.getIs_login()==0)
{
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, new LoginFragment())
.commit();
}
else
{
getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);

getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, new DashboardFragment())
.commit();

MainActivity.mRightMenuSelectedItem = com.srt.educras.enumerator.right_menu_type.Dashboard.getNumericType();

getSlidingMenu().setSecondaryMenu(R.layout.frame_right_menu);
getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);

getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frame_rightmenu_layout, new right_menu())
.commit();
}

//setSlidingActionBarEnabled(false);

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.actionbar_layout);

//getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//getActionBar().setCustomView(R.layout.actionbar_layout);

//txtTitle = (TextView)findViewById(R.id.actionBarTitle1);

btnShowMenu = (ImageView)this.findViewById(R.id.btnShowMenu);
btnShowSecondaryMenu = (ImageView)this.findViewById(R.id.btnShowSecondaryMenu);

btnShowSecondaryMenu.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if(getSlidingMenu().isMenuShowing())
showContent();
else
getSlidingMenu().showSecondaryMenu(true);
}
});

btnShowMenu.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if(getSlidingMenu().isMenuShowing())
showContent();
else
getSlidingMenu().showMenu(true);
}
});

if(MainActivity.list_students.isEmpty())
{
//txtTitle.setText("Add new account");
btnShowSecondaryMenu.setVisibility(View.GONE);
}
//else
// txtTitle.setText(obj_student.getStudent_name());

SlidingMenu sm = getSlidingMenu();
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

No comments:

Post a Comment