Slide Frame--slidingmenu

Source: Internet
Author: User

first, import the downloaded libary package into the project

Ii. initializing the side-slip menu in the project

public void Initslidingmenu () {slidingmenu menu = new Slidingmenu (this);Set the slide-slip mode to the left side slide menu. SetMode(Slidingmenu. Left);            / * * Set Drag mode slidingmenu.touchmode_fullscreen full Screen touch effective * slidingmenu.touchmode_margin Drag edge effective Slidi Ngmenu.touchmode_none * Do not respond to touch events */Menu. Settouchmodeabove(Slidingmenu. Touchmode_fullscreen);Set the width of the shadow menu. Setshadowwidthres(R. Dimen. Shadow_width);Set a picture of a shadow menu. Setshadowdrawable(R. drawable. Shadow);Set the remaining size of the sldingmenu---= the DP size corresponding to the Content Display page menu. Setbehindoffsetres(R. Dimen. Slidingmenu_offset);Set the degree of gradient when sliding menu. Setfadedegree(0.35F;Attach the Slidingmenu to the activity right//Slidingmenu. SLIDING_content set the skid bar to the content location//Slidingmenu. SLIDING_window set the slide bar to render the menu in the entire window. Attachtoactivity(This, slidingmenu. SLIDING_content);Set the layout of the Slidingmenu Association menu. SetMenu(R. Layout. Menu_layout);Querying a control in a slidingmenu associated layout ListView lv_list = (ListView) Menu. Findviewbyid(R. ID. LV);Simple Setup Slidingmenu interface display content arraylist<string> strlist = new Arraylist<string> ();for (int i =0; i <; i++) {Strlist. Add("section"+ i +"Entry");}//Set data adapter Lv_list. Setadapter(New Arrayadapter<string> (This, Android. R. Layout. Simple_list_item_1, Strlist));}

create the appropriate layout file

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <gradient        android:centerColor="#ccc"        android:endColor="#ccc"        android:startColor="#ccc" /></shape>

<resources>    <!--Default screen margins, per the Android Design guidelines.    <dimen name="Activity_horizontal_margin">16dp</dimen>    <dimen name="Activity_vertical_margin">16dp</dimen>    <dimen name="Shadow_width">2dp</dimen>    <dimen name="Slidingmenu_offset">160dp</dimen></Resources>

Resolving the conflict between Viewpager and skidding

Vp_pager.setonpagechangelistener (NewOnpagechangelistener () {@Override             Public void onpageselected(intARG0) {if(arg0 = =0) {Menu.settouchmodeabove (slidingmenu.touchmode_fullscreen); }Else{//When in other locations, the settings can not be dragged out (slidingmenu.touchmode_none), or only in the edge position can be dragged out Touchmode_marginMenu.settouchmodeabove (Slidingmenu.touchmode_none); }            }@Override             Public void onpagescrolled(intARG0,floatArg1,intARG2) {//TODO auto-generated method stub}@Override             Public void onpagescrollstatechanged(intARG0) {//TODO auto-generated method stub}        });

Click the button slide -out box to pull

 1.The first type of code Iv_image.setonclicklistener (NewOnclicklistener () {@Override             Public void OnClick(View v) {if(Menu.ismenushowing ())                {menu.showcontent (); }Else{Menu.showmenu (); }            }        });2.The second type of code Iv_image.setonclicklistener (NewOnclicklistener () {@Override             Public void OnClick(View v) {//Menu.toggle (); }        });

Slide Frame--slidingmenu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.