AdapterViewFlipper的用法
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterViewFlipper;
import android.widget.BaseAdapter;
import android.widget.ImageView;


public class MainActivity extends Activity {

int[] imageIds=new int[]{
R.drawable.w_001,
R.drawable.w_002,
R.drawable.w_003,
R.drawable.w_004,
R.drawable.w_005,
R.drawable.w_006,
};


private AdapterViewFlipper flipper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

flipper=(AdapterViewFlipper)findViewById(R.id.flipper);

BaseAdapter adapter=new BaseAdapter()
{


@Override
public int getCount() {

return imageIds.length;
}


@Override
public Object getItem(int position) {
return position;
}


@Override
public long getItemId(int position) {
return position;
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView=new ImageView(MainActivity.this);
imageView.setImageResource(imageIds[position]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
return imageView;
}

};
flipper.setAdapter(adapter);
}
public void prev(View source){
flipper.showPrevious();
flipper.stopFlipping();
}
public void next(View source){
flipper.showNext();
flipper.stopFlipping();
}
public void auto(View source){
flipper.startFlipping();
}
}
阅读更多
文章标签: AdapterViewFlipper
个人分类: Android开发
想对作者说点什么? 我来说一句

AdapterViewFlipper与Gallery比较demo

2014年04月23日 1.58MB 下载

AdapterViewFlipper简单实例

2015年05月06日 1.39MB 下载

没有更多推荐了,返回首页

不良信息举报

AdapterViewFlipper的用法

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭