Last active
March 11, 2016 11:01
-
-
Save raizal/1820477feb3d5a08e0c7 to your computer and use it in GitHub Desktop.
Simple Slide Show
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DetailActivity extends AppCompatActivity { | |
@Bind(R.id.slideshow) | |
ViewPager slideshow; | |
private List<String> slideShowImages = new ArrayList<>(); | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_fragment); | |
ButterKnife.bind(this); | |
setSupportActionBar(toolbar); | |
slideShowImages.add("http://cdn1.360cities.net/pano/rami-saarikorpi/00574590_Kauppatori.jpeg/equirect_crop_3_1/5.jpg"); | |
slideShowImages.add("http://www.360p.co.uk/wp-content/uploads/2011/04/360-panoramas-perran-dunes-1200x600.jpg"); | |
slideShowImages.add("http://www.360p.co.uk/wp-content/uploads/2011/05/360-panoramas-truro-park-3-1200x600.jpg"); | |
slideshow.setAdapter(new SlideShowAdapter(getSupportFragmentManager())); | |
} | |
private class SlideShowAdapter extends FragmentPagerAdapter{ | |
public SlideShowAdapter(FragmentManager fm) { | |
super(fm); | |
} | |
@Override | |
public Fragment getItem(int position) { | |
return new SlideShowItemFragment().putImage(slideShowImages.get(position)); | |
} | |
@Override | |
public int getCount() { | |
return slideShowImages.size(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:scaleType="centerCrop"> | |
</ImageView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.superbro.myride.search.view; | |
import android.graphics.Bitmap; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.Fragment; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; | |
import com.nostra13.universalimageloader.core.ImageLoader; | |
import com.superbro.myride.MyApplication; | |
import com.superbro.myride.R; | |
import com.superbro.myride.utils.Utils; | |
/** | |
* Created by raizal.pregnanta on 06/03/2016. | |
*/ | |
public class SlideShowItemFragment extends Fragment { | |
private String image; | |
public SlideShowItemFragment putImage(String image){ | |
this.image = image; | |
return this; | |
} | |
@Nullable | |
@Override | |
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
View v = inflater.inflate(R.layout.slideshow_item,container,false); | |
ImageView iv = ((ImageView)v); | |
ImageLoader.getInstance().displayImage(image,iv, Utils.getUILOption()); | |
return v; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
.... | |
<android.support.v4.view.ViewPager | |
android:id="@+id/slideshow" | |
android:layout_width="match_parent" | |
android:layout_height="280dp" | |
android:layout_marginBottom="15dp"> | |
.... | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment