AndroidSweetSheet

½éÉÜ£º

Ò»¸ö¸»Óж¯¸ÐµÄSheet(Ñ¡ÔñÆ÷)£¬ Ö§³Ö±³¾°Ð黯,±³¾°°µ»¯,Ö§³Ö¿ìËÙÍØÕ¹.Ö§³Ö´Ó Menu ÖÐÌî³äÊý¾Ý¡£

ÔËÐÐЧ¹û£º

ʹÓÃ˵Ã÷£º

ÉÏÃæÊÇÉè¼Æͼ£¬demoÔËÐÐЧ¹ûͼ£º

MainActivity.class

    //Ìí¼Ó¼ÙÊý¾Ý
    MenuEntity menuEntity=new MenuEntity();
    menuEntity.resId=R.drawable.ic_account_child;
    menuEntity.name="QQ";
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    list.add(menuEntity);
    //¸ù¾ÝTypeÉú³É¶ÔÓ¦µÄÑùʽ SweetSheet ¿Ø¼þ,¸ù¾Ý rl È·ÈÏλÖÃ
    mSweetSheet = new SweetSheet(rl, SweetSheet.Type.RecyclerView);
    //ÉèÖÃÊý¾ÝÔ´ FragmentManager ÔÚÑùʽΪViewpager ÊDZØÐëµÄ, RecyclerViewÑùʽ¿ÉÒÔΪ null, ²»Ó°ÏìÔËÐÐ
    mSweetSheet.setMenuList(getSupportFragmentManager(), list);
    //ÉèÖñ³¾°»Ò¶È
    mSweetSheet.setBackgroundDim(0.8f);
    //ÉèÖõã»÷ʼþ
    mSweetSheet.setOnMenuItemClickListener(new SweetSheet.OnMenuItemClickListener() {
    @Override
    public boolean onItemClick(int position) {
            //¸ù¾Ý·µ»ØÖµ, true »á¹Ø±Õ SweetSheet ,false Ôò²»»á.
            Toast.makeText(MainActivity.this,list.get(position).name+"             "+position,Toast.LENGTH_SHORT).show();
            return true;
        }
    });

¼àÌý·µ»Ø

    @Override
    public void onBackPressed() {
        if(mSweetSheet.isShow()){
            mSweetSheet.dismiss();
        }
        else{
            super.onBackPressed();
        }
    }

×¢Òâ:

  1. Ä¿Ç°SweetSheetÖ§³ÖµÄÑùʽ2ÖÖ:SweetSheet.Type.RecyclerView ºÍ SweetSheet.Type.Viewpager

  2. ¹ØÓÚ:SweetSheet.setMenuList(FragmentManager fm, LIst list); µÚÒ»¸ö²ÎÊýÊÇÓÃÁË×öViewPagerµÄÊÊÅäÆ÷ʹÓõÄ,ÀàÐÍSweetSheet.Type.RecyclerView ¿ÉÒÔ´«null;

  3. Ôݲ»Ö§³ÖʹÓÃLinearLayout ×÷ΪmSweetSheet µÄ¸¸¿Ø¼þ.

Ìصã (1.1):

  1. Ö§³Ö´ÓmenuÖд´½¨.

  2. ÓÅ»¯SweetSheet.Type.RecyclerView µÄÌåÑé.

  3. gradleµÄÖ§³Ö

  4. Ö§³Ö¼òµ¥µÄÀ©Õ¹

已下载
0