zoukankan      html  css  js  c++  java
  • 安卓桌面分页

    1.适配器:

    package com.example.adapter;
    
    import java.util.ArrayList;
    
    import android.annotation.SuppressLint;
    import android.app.ActionBar.LayoutParams;
    import android.support.v4.view.PagerAdapter;
    import android.view.View;
    import android.view.ViewGroup;
    
    public class MyViewPagerAdapter extends PagerAdapter{
        private ArrayList<View>mlist;
        public MyViewPagerAdapter(ArrayList<View>mlist){
            super();
            this.mlist=mlist;
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return this.mlist==null?0:this.mlist.size();
        }
    
        @Override
        public boolean isViewFromObject(View arg0, Object arg1) {
            // TODO Auto-generated method stub
            return arg0==arg1;
        }
        public void destroyItem(ViewGroup container,int position,Object object){
            container.removeView(this.mlist.get(position));
        }
        @SuppressLint("NewApi")
        public Object instantiateItem(ViewGroup container,int position){
            LayoutParams lp=new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
            container.addView(this.mlist.get(position),lp);
            return this.mlist.get(position);
        }
    
    }
    2.activity:
    package com.example.adapter;
    
    import java.util.ArrayList;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.support.v4.view.ViewPager;
    import android.text.Layout;
    import android.view.View;
    import android.view.ViewGroup.LayoutParams;
    import android.widget.ImageView;
    import android.widget.ImageView.ScaleType;
    
    public class ViewPageActivity extends Activity{
        private int[]imgs={
                R.drawable.bbe609315da7a9bfa65df713e7c168e0,
                R.drawable.bc494385774b8343123c5697ebeaeb9,
                R.drawable.dd6709ab53006f11f393e58f2ba614c4,
                R.drawable.e8d145de5ffdf97a4407ab4c5dd33513,
                R.drawable.eecfd0d328203e8a15366658231c3174
        };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.viewpagelayout);
            ViewPager viewPager=(ViewPager) findViewById(R.id.myPager);
            ArrayList<View>mlist=new ArrayList<View>();
            for(int i=0;i<imgs.length;i++){
                ImageView imgView=new ImageView(this);
                imgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
                imgView.setScaleType(ScaleType.FIT_XY);
                imgView.setImageResource(imgs[i]);
                mlist.add(imgView);
            }
            MyViewPagerAdapter adapter=new MyViewPagerAdapter(mlist);
            viewPager.setAdapter(adapter);
        }
        
    
    }
    
    
    


  • 相关阅读:
    初识ASP.net-牛腩新闻公布系统
    【React Native开发】React Native控件之RefreshControl组件具体解释(21)
    Drupal 主题的表现形式
    OAF 设置右对齐
    在页面和请求中分别使用XML Publisher生成PDF报表且自动上传至附件服务器
    在请求的参数中设置可选值列表为当前职责可访问的所有OU
    校验基于EO的VO中的字段是否发生变化
    在使用DBMS_LOB.WRITEAPPEND()追加Clob内容的时候,报数字或值异常
    OAF中下载附件之后页面失效,报过时的数据异常,浏览器后退异常
    JAVA 中CLOB与Clob有区别
  • 原文地址:https://www.cnblogs.com/zhongshujunqia/p/3948504.html
Copyright © 2011-2022 走看看