GridView ,ViewPager
GridViwe,与listView都是AdapterView的子类,
*在Activity中添加GridView控件;
*获去数据源 注:本地或网络数据都需要封装到List集合中。
*创建列表项的布局;
*创建Adapter
*在Activity中初始化GridView控件,创建Adapter对象,并为G日的VIew配置适配器
注:GridView的监听器也是onItemClickLIstener
ViewPager;
ViewPager需要使用PagerAdapter协调需要显示的子集View对象,
ViewPage的开发流程大致如下:
*在Activity布局中添加ViewPager控件;
<android.support.v4.view.ViewPager
android:id="@+id/vp_pager"
............width=..............
....height.......
注;无法预览效果
...............................
*在res/layout/下创建各子集View对象的布局文件;
*在Activity的程序中初始化VIewPager控件;
*在Activity的程序中初始化各子集View对象,使用List集合或数组进行存储;
*private List<VIew>childViews;
childViews=new ArrayList<View>();
childVews.add(getLayoutInflater().inflate(R.layout.page1,null));
*创建pagerAdapter
private class InnerViewPagerAdapter extends PagerAdapter{
}
@override
.........getCout(){}
@override
.........isViewFromOBject(View arg0,Object arg1){
return arg0=arg1; }
@override
.........destrouItem(ViewGroup containew,int position,Object object){
containew.removeView(childView.get(position));
@override
.........instantateItem(ViewGroup container,int position){
View view=childViews.get(position);
containew.addVIew(viwe};
return view;
}
*为VIewPager配置pagerAdapter;
..................
viewPager=()findViewById();
.................
childViews=new ArrayList<View>();
childViews.add().inflater();
VeiwPager.setAdapter();