Android?л??????ViewPager
???????????? ???????[ 2015/5/12 13:30:45 ] ?????????????????
?????й???????????????????????Ч????????????????????????????????????????л?Ч?????????????????????????????°????????1.0???????????????????????????????????????????????????????
????????????????ViewPager??????ViewPager???????????????????????ViewPager?????????????????????
????????ж???Ч?????????????????????????л?Ч????
?????????????
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.example.android_viewpager.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.example.android_viewpager.ViewPager>
</RelativeLayout>
?????????Activity:
public class MainActivity extends Activity {
private ViewPager mViewPager;//??????
int [] imageIds = {R.drawable.guide_image1?? R.drawable.guide_image2?? R.drawable.guide_image3};
List<ImageView> listImager = new ArrayList<ImageView>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mViewPager = (ViewPager) findViewById(R.id.viewPager);//??????????
mViewPager.setAdapter(new PagerAdapter() {
@Override
public void destroyItem(ViewGroup container?? int position??
Object object) {
container.removeView(listImager.get(position));
}
@Override
public Object instantiateItem(ViewGroup container?? int position) {
ImageView imagerView = new ImageView(MainActivity.this);
imagerView.setImageResource(imageIds[position]);
imagerView.setScaleType(ScaleType.CENTER_CROP);//???????
container.addView(imagerView);
listImager.add(imagerView);
return imagerView;
}
@Override
public boolean isViewFromObject(View arg0?? Object arg1) {
return arg0 == arg1;
}
@Override
public int getCount() {
return imageIds.length;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main?? menu);
return true;
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11