SlidingMume

import java.util.ArrayList;
import java.util.List;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
import com.viewpagerindicator.TabPageIndicator;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class MainActivity extends SlidingFragmentActivity {
private ViewPager viewPager;
private static final String[] ss = new String[] {“推荐”,”热点”,”视频”,”社会”,”娱乐”,”科技”,”汽车”,”美女”,”体育”};
//List list=new ArrayList();
private ImageView imageView1, imageView2;
@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewPager=(ViewPager) findViewById(R.id.vp);
    viewPager.setAdapter(new MyPageAdapter(getSupportFragmentManager(),ss));

    getinit();
    TabPageIndicator tpi=(TabPageIndicator) findViewById(R.id.tpi);
    //ViewPager,
    tpi.setViewPager(viewPager);
    tpi.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

        }
    });
}
private void getinit() {
    // TODO Auto-generated method stub
    Left f=new Left();
    setBehindContentView(R.layout.frament1);
    getSupportFragmentManager().beginTransaction().replace(R.id.fr1, f)
            .commit();

    final SlidingMenu menu = getSlidingMenu();
    menu.setMode(SlidingMenu.LEFT);

    //滑出菜单的模式                              手指紧贴边缘划出
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    //SlidingMenu滑动时的 渐变程度ֵ
    menu.setFadeDegree(1.0f);
    //
    menu.setBehindWidth(20);
    //
    menu.setBehindOffset(80);

    menu.setMenu(R.layout.frament1);

    imageView1 = (ImageView) findViewById(R.id.iv_main_user);
    imageView1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.showMenu();
        }
    });
}

}

你可能感兴趣的:(SlidingMume)