Back to project page subsampling-scale-image-view.
The source code is released under:
Apache License
If you think the Android project subsampling-scale-image-view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* Copyright 2014 David Morrissey/* www. j a v a2s.c om*/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.davemorrissey.labs.subscaleview.sample; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import com.davemorrissey.labs.subscaleview.sample.viewpager.ViewPagerFragment; public class SampleActivity extends FragmentActivity { private static final String[] IMAGES = { "card1.png", "card2.png", "card3.png", "DSC04285.JPG", "DSC03250.JPG" }; private ViewPager page; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); PagerAdapter pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); page = (ViewPager)findViewById(R.id.pager); page.setAdapter(pagerAdapter); } @Override public void onBackPressed() { if (page.getCurrentItem() == 0) { super.onBackPressed(); } else { page.setCurrentItem(page.getCurrentItem() - 1); } } private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { public ScreenSlidePagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { return new ViewPagerFragment(IMAGES[position]); } @Override public int getCount() { return IMAGES.length; } } }