package xushuai.viewpager_indicator_demo; import android.os.Bundle; import android.support.v4.view.ViewPager; import com.viewpagerindicator.CirclePageIndicator; public class SampleCirclesSnap extends BaseSampleActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_circles); CircleAdapter mAdapter = new CircleAdapter(getSupportFragmentManager()); mPager = (ViewPager)findViewById(R.id.pager); mPager.setAdapter(mAdapter); CirclePageIndicator indicator = (CirclePageIndicator)findViewById(R.id.indicator); mIndicator = indicator; indicator.setViewPager(mPager); indicator.setSnap(true); } }