Android ViewPager extends bandwidth» ­ § extends bandwidth

Source: Internet
Author: User

Android ViewPager extends bandwidth» copyright § extends bandwidth

Õ Ò µ½ ö²» 'í µä¿ Ô 'Ï Ä ä£ £° https: // github.com/jfeinstein10/JazzyViewPager

Android ViewPager extends bandwidth» copyright § extends bandwidth

<Symbol · blank "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> vcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20141126/2014112608433590.png" alt = "\">

~~~Ä~~~£° £\%â ö öê çviewpager µä ~~~~» ~~~~~~~~~~~~~~**************************** £.

package com.example.jaazy;import java.util.ArrayList;import android.support.v4.view.PagerAdapter;import android.view.View;import android.view.View.OnClickListener;import android.view.ViewGroup;/** * Create by LanYan on 2014.04.24 * This is a adapter */public class ViewPagerAdapterOnClick extends PagerAdapter {private ArrayList
 
   views;private ViewPageOnClick callback;private JazzyViewPager pager;public ViewPagerAdapterOnClick(JazzyViewPager pager,ArrayList
  
    views,ViewPageOnClick callback) {this.setViews(views);this.callback=callback;this.pager=pager;}public void setViews(ArrayList
   
     views) {if (views != null)this.views = views;elsethis.views = new ArrayList
    
     ();}public void changeItem(ArrayList
     
       views) {this.setViews(views);notifyDataSetChanged();}@Overridepublic int getItemPosition(Object object) {// TODO Auto-generated method stubreturn POSITION_NONE;}@Overridepublic int getCount() {// TODO Auto-generated method stubreturn views.size();}@Overridepublic boolean isViewFromObject(View arg0, Object arg1) {// TODO Auto-generated method stubreturn arg0 == arg1;}@Overridepublic void destroyItem(ViewGroup container, int position, Object object) {View v = views.get(position);container.removeView(v);}public void removeUpdate(ViewGroup container){container.removeAllViews();}@Overridepublic Object instantiateItem(ViewGroup container, final int position) {View v = views.get(position);v.setOnClickListener(new OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stubcallback.callbackOnClickItem(position);}});container.addView(v);pager.setObjectForPosition(v, position);return v;}public interface ViewPageOnClick{void callbackOnClickItem(int position);}}
     
    
   
  
 
Activity:

import java.util.ArrayList;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.ViewGroup.LayoutParams;import android.widget.ImageView;import android.widget.Toast;import com.example.jaazy.JazzyViewPager.TransitionEffect;import com.example.jaazy.ViewPagerAdapterOnClick.ViewPageOnClick;public class MainActivity extends Activity implements ViewPageOnClick{private JazzyViewPager pager;private ViewPagerAdapterOnClick adapter;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);setupJazziness(TransitionEffect.Stack);}private void setupJazziness(TransitionEffect stack) {// TODO Auto-generated method stubpager=(JazzyViewPager)findViewById(R.id.jazzy_pager);adapter=new ViewPagerAdapterOnClick(pager, getViews(),this);pager.setAdapter(adapter);pager.setPageMargin(5);//ѹջ·½Ê½pager.setTransitionEffect(TransitionEffect.Stack);//Á¢ÌåÄÚ²¿½ø³ö//pager.setTransitionEffect(TransitionEffect.CubeIn);//Á¢Ìå͹³ö//pager.setTransitionEffect(TransitionEffect.CubeOut);//×óÓÒ¼·Ñ¹//pager.setTransitionEffect(TransitionEffect.Accordion);//Ëƽ·Ò³//pager.setTransitionEffect(TransitionEffect.FlipHorizontal);//´¹Ö±·Ò³//pager.setTransitionEffect(TransitionEffect.FlipVertical);//ÉÏÉÈÐΰÚÈë//pager.setTransitionEffect(TransitionEffect.RotateDown);//ÏÂÉÈÐΰÚÈë//pager.setTransitionEffect(TransitionEffect.RotateUp);//±ê×¼//pager.setTransitionEffect(TransitionEffect.Standard);//Ñ¡Ï£¨¿¨Æ¬ÐÎʽ£///pager.setTransitionEffect(TransitionEffect.Tablet);//zoom in//pager.setTransitionEffect(TransitionEffect.ZoomIn);//zoom out//pager.setTransitionEffect(TransitionEffect.ZoomOut);}private ArrayList
 
   getViews() {// TODO Auto-generated method stubArrayList
  
    list=new ArrayList
   
    ();ImageView i=new ImageView(this);LayoutParams params=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);i.setLayoutParams(params);i.setBackgroundResource(R.drawable.a);ImageView i2=new ImageView(this);i2.setLayoutParams(params);i2.setBackgroundResource(R.drawable.b);ImageView i3=new ImageView(this);i3.setLayoutParams(params);i3.setBackgroundResource(R.drawable.c);ImageView i4=new ImageView(this);i4.setLayoutParams(params);i4.setBackgroundResource(R.drawable.e);list.add(i);list.add(i2);list.add(i3);list.add(i4);return list;}@Overridepublic void callbackOnClickItem(int position) {// TODO Auto-generated method stubToast.makeText(this, "position:"+position, 1000).show();}}
   
  
 
JazzyViewPager × ø 'ø zookeeper» zookeeper 11ö~£' martéé


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.