SlidingMenu(jfeinstein) - How to control secondary sliding menu - android

I am using jfenstein's sliding menu lib. But I need to control two sliding menus separately. Sometimes second has to be disabled.And sometimes first slidingmenu has to be disabled.
When I have used menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); both of them effected.
This my code :
menu = new SlidingMenu(activity);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowDrawable(R.drawable.sliding_menu_shadow);
menu.setBehindOffsetRes(R.dimen.sliding_menu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(activity, SlidingMenu.SLIDING_WINDOW);
menu.setMenu(R.layout.sliding_menu_frame);
menu.setMode(SlidingMenu.LEFT_RIGHT);
SlidingMenuListFragment slidingMenuListFragment = new SlidingMenuListFragment();
slidingMenuListFragment.setMenuBuilder(this);
/*
* left menu
*/
activity.getSupportFragmentManager().beginTransaction()
.replace(R.id.sliding_menu_frame, slidingMenuListFragment)
.commit();
/*
* right menu
*/
SlidingMenuListFragment rightMenu = new SlidingMenuListFragment();
rightMenu.setMenuBuilder(this);
menu.setSecondaryMenu(R.layout.sliding_menu_frame);
activity.getSupportFragmentManager()
.beginTransaction()
.replace(R.id.sliding_menu_frame, rightMenu )
.commit();

I have the same problem and I fix it with the following :
//can open left and right panel
menu.setMode(SlidingMenu.LEFT_RIGHT);
//can only open left panel and show only left (perhaps overlay the right panel ?)
menu.setMode(SlidingMenu.LEFT);
but it only works to "disable/make invisible" the right panel
if you do :
menu.setMode(SlidingMenu.RIGHT);
it only show the left panel on the right.

Related

Swipe to close sliding menu by J.Feinstein

I am using J.Feinstein library of sliding menu and it works great... The only problem i have is that it closes only if i touch outside the sliding menu or if i swipe from right to left from outside the sliding menu..
But what actually i want is that it will also swipe from right to left to close when i swipe it by finger on it, not only from outside of it...
I searched a lot.. In fact i read the source code of library and found the function getSlidingMenu(true); but that does not fulfill my requirement .. I am new to android... Kindly help me out and tell me how to do this..
Here is my piece of code..
public class ViewPagerActivity extends SlidingFragmentActivity{
// Tab titles
private String[] tabs = { "First", "Second", "Third" };
public ViewPagerActivity() {
super();
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.viewpager);
setContentView(R.layout.pager);
// customize the SlidingMenu
final 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.setScrollBarStyle(2);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
//sm.setSlidingEnabled(true);
//sm.setTouchmodeMarginThreshold(2);
getSlidingMenu().setSlidingEnabled(true);
setBehindContentView(R.layout.menu_frame);
}
}
If you want this type of sliding then use view pager with sliding....
http://javapapers.com/android/android-image-slider-tutorial/
this will surely help you and you will no have to face this kind of problem...

Android view jfeinstein SlidingMenu top of layouts without move content

by default jfeinstein SlidingMenu move content to view slide menu layout, but i dont like that and i want to view slide menu without move content and top of all layouts.
in this below screen shot i like number 2
Default settings are :
public class SlidingExample extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.attach);
// set the content view
setContentView(R.layout.content);
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);
}
}
and i'm could not find whats setting view slide menu top of all layouts ans widgets after any testing attachToActivity
wild guess (I don't use jFeinstein)..
when the slider activates, to remove the 'hamburger' icon from the ABar get rid of "home_as_up"...
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
ActionBar.DISPLAY_USE_LOGO |ActionBar.DISPLAY_HOME_AS_UP,
ActionBar.DISPLAY_HOME_AS_UP
| ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);

jfeinstein10/SlidingMenu attaching a Fragment

I'm trying to implement the jfeinsteins sliding menu, however I'm having a problem getting a fragment to attach. The issue is that the layout is shown on the screen twice. I assume that this is because I setMenu and then do the replace (adding it again).
Could anyone provide some pointers please.
public void configureSlidingMenu()
{
// configure the SlidingMenu
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.RIGHT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setFadeDegree(0.35f);
menu.setBehindOffset(120);
menu.setMenu(R.layout.fragment_slideoutmenu);
getFragmentManager()
.beginTransaction()
.replace(R.id.slideOutMenu, new SlideOutMenu())
.commit();
}
I did this in my application...
Created a class Util like this:
public class Util {
public static void atachLeftMenu(final Activity pActivity){
final SlidingMenu menu = new SlidingMenu(pActivity);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(pActivity, SlidingMenu.SLIDING_WINDOW);
menu.setMenu(R.layout.side_menu);
( (ListView)(menu.findViewById(R.id.side_menu_list)) ).setAdapter(new leftMenuAdapter(pActivity));
( (ListView)(menu.findViewById(R.id.side_menu_list)) ).setOnItemClickListener( new DrawerItemClickListener(pActivity));
//Set menu options and values
}
}
And in every Activity i just call the Util's "atachLeftMenu" method.
Util.atachLeftMenu(this);
If you want to do it within a fragment you'll still have to pass it the activity so you could do something like this:
Util.atachLeftMenu(getActivity());

Sliding menu bar is over-riding ViewPager tabs. How to stop that from happening?

I'm using this library for my Sliding Menu. https://github.com/jfeinstein10/SlidingMenu
My biggest problem with this is that, I'm using a ViewPagerIndicator. Thus, say I've three tabs that I've added to the viewpager, in which I've inflated 3 fragments, Tab1, Tab2, Tab3.
While swiping from right to left, I go from Tab1 to Tab2. While Swiping from left to right at Tab1, the sliding menu opens.
But say I'm in tab2, and I swipe from left to right. This should open up tab 1 and not the sliding menu, which it does here.
In my BaseActivity, this is the code I've added:
menu = new SlidingMenu(this);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
//menu.setShadowWidthRes(R.dimen.shadow_width);
//menu.setShadowDrawable(R.drawable.shadow);
// menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.base_layout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
How do I stop the slide menu to slide when I'm not in Tab1?
You should check out its provided sample app, sample always gives you great unexpected solutions.
yourViewPagerIndicator.setOnPageChangeListener(new OnPageChangeListener() {
#Override
public void onPageScrollStateChanged(int arg0) { }
#Override
public void onPageScrolled(int arg0, float arg1, int arg2) { }
#Override
public void onPageSelected(int position) {
switch (position) {
case 0:
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
break;
default:
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
break;
}
}
});
Another way you can stop slide menu by call getSlidingMenu().setSlidingEnabled(false); when you in Tab layout

SlidingMenu and header

I begin to use a slidingMenu. In my application I have a header with button. when I move it sliding, than my header move too. But I want, than my header do not move, and sliding menu move under header. My header is not actionBar, usual layout.
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
// ///////////
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
// //////////
menu.setMenu(R.layout.menu);
How I can do what I want?
You have to assign a button to action toggle from sliding.
findViewById(R.id.buttonToggle).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
getSlidingMenu().toggle(true);
}
});

Categories

Resources