viewpager是用在滾動(dòng)中相對(duì)比較多的走孽,最近做一個(gè)定時(shí)滾動(dòng)顯示viewpager內(nèi)容念逞。
步驟:
一:在布局文件添加v4包下的viewpager:
android:id="@+id/main_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
二:獲取后臺(tái)數(shù)據(jù),現(xiàn)在就暫時(shí)自己造幾條數(shù)據(jù)创淡,并寫adapter內(nèi)容
//構(gòu)造list集合
list=newArrayList();
list.add(R.mipmap.image1);
list.add(R.mipmap.image2);
list.add(R.mipmap.image3);
//我這邊是顯示的viewpager的很多信息,包括圖片文字劳较,所以構(gòu)造view墓捻,在Java中寫布局代碼凸丸,
這個(gè)時(shí)候就需要我們構(gòu)造view环肘,privateListmList=new ArryList;
循化list集合數(shù)據(jù)腌零,創(chuàng)建頁(yè)面詳情,通過(guò)add方法加載到mList记舆,這樣adapter中就可以傳遞過(guò)去值了:
for(inti =0;i
rootlayout=newRelativeLayout(this);
rootlayout.setLayoutParams(newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
rootlayout.setId(0);
ImageView imageView =newImageView(this);
RelativeLayout.LayoutParams image_Params =newRelativeLayout.LayoutParams(
dip2px(250),dip2px(192));
image_Params.setMargins(dip2px(5),0,dip2px(5),dip2px(5));
imageView.setLayoutParams(image_Params);
imageView.setImageResource(list.get(i));
//Picasso.with(ViewPagersActivity.this).load(tsfbBeans.get(i).getBook_pic()).error(R.mipmap.image1).into(imageView);
imageView.setId(1);
//字體顏色
Resources resource = (Resources) getBaseContext().getResources();
ColorStateList csl = (ColorStateList) resource.getColorStateList(R.color.book_text);
TextView text_Name =newTextView(this);
RelativeLayout.LayoutParams text_Name_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Name_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_Name_Params.addRule(RelativeLayout.ALIGN_TOP,imageView.getId());
text_Name_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_Name.setLayoutParams(text_Name_Params);
text_Name.setText("圖書描述:");
//text_Name.setText(tsfbBeans.get(i).getBook_name() + ":");
text_Name.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_Name.setTextColor(csl);
text_Name.setId(2);
TextView text_Email =newTextView(this);
RelativeLayout.LayoutParams text_Email_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Email_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_Email_Params.addRule(RelativeLayout.BELOW,text_Name.getId());
text_Email_Params.setMargins(dip2px(10),dip2px(5),dip2px(10),0);
text_Email.setLayoutParams(text_Email_Params);
text_Email.setText("《詩(shī)經(jīng)》是中國(guó)古代詩(shī)歌開端摘能,最早的一部詩(shī)歌總集峻黍,收集了西周初年至春秋中葉(前11世紀(jì)至前6世紀(jì))的詩(shī)歌,共311篇黎侈,其中6篇為笙詩(shī),即只有標(biāo)題希太,沒有內(nèi)容亡脑,稱為笙詩(shī)六篇");
//text_Email.setText(tsfbBeans.get(i).getBook_description());
text_Email.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);
text_Email.setId(3);
TextView text_author =newTextView(this);
RelativeLayout.LayoutParams text_author_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_author_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_author_Params.addRule(RelativeLayout.BELOW,text_Email.getId());
text_author_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_author.setLayoutParams(text_author_Params);
text_author.setText("圖書作者:");
//text_author.setText("圖書作者:" + tsfbBeans.get(i).getBook_author());
text_author.setTextColor(csl);
text_author.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_author.setId(4);
TextView text_place =newTextView(this);
RelativeLayout.LayoutParams text_place_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_place_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_place_Params.addRule(RelativeLayout.BELOW,text_author.getId());
text_place_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_place.setLayoutParams(text_place_Params);
text_place.setText("出版社:");
//text_place.setText("出版社:" + tsfbBeans.get(i).getBook_publishing());
text_place.setTextColor(csl);
text_place.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_place.setId(5);
TextView text_data =newTextView(this);
RelativeLayout.LayoutParams text_data_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_data_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_data_Params.addRule(RelativeLayout.BELOW,text_place.getId());
text_data_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_data.setLayoutParams(text_data_Params);
text_data.setText("出版日期:");
// text_data.setText("出版日期:" + tsfbBeans.get(i).getBook_publication_date());
text_data.setTextColor(csl);
text_data.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_data.setId(6);
TextView text_description_name =newTextView(this);
RelativeLayout.LayoutParams text_DescriptionName_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_DescriptionName_Params.addRule(RelativeLayout.BELOW,imageView.getId());
//text_Name_Params.addRule(RelativeLayout.ALIGN_TOP, imageView.getId());
text_DescriptionName_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_description_name.setLayoutParams(text_DescriptionName_Params);
text_description_name.setText("圖書簡(jiǎn)介:");
text_description_name.setTextColor(csl);
text_description_name.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_description_name.setId(7);
TextView text_description =newTextView(this);
RelativeLayout.LayoutParams text_Description_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Description_Params.addRule(RelativeLayout.BELOW,text_description_name.getId());
//text_Name_Params.addRule(RelativeLayout.ALIGN_TOP, imageView.getId());
text_Description_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_description.setLayoutParams(text_Description_Params);
text_description.setText("111");
//text_description.setText(tsfbBeans.get(i).getBook_abstract());
text_description.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);
text_description.setId(8);
rootlayout.addView(imageView,image_Params);
rootlayout.addView(text_Name,text_Name_Params);
rootlayout.addView(text_Email,text_Email_Params);
rootlayout.addView(text_description,text_Description_Params);
rootlayout.addView(text_author,text_author_Params);
rootlayout.addView(text_place,text_place_Params);
rootlayout.addView(text_data,text_data_Params);
rootlayout.addView(text_description_name,text_DescriptionName_Params);
//setContentView(rootlayout);
mList.add(rootlayout);
}
來(lái)講講adapter,基本寫法就行坑傅,但是注意的是在添加view的時(shí)候必須保證是一個(gè)view的parent喷斋,要不然報(bào)錯(cuò):
public classTTMyPagerAdaptersextendsPagerAdapter {
publicListlistViews=null;
publicTTestViewPagersActivitymContext;
publicTTMyPagerAdapters(List listViews,TTestViewPagersActivity mContext) {
this.listViews= listViews;
this.mContext= mContext;
Share.d("listviews"+ listViews.size());
}
@Override
public intgetCount() {
returnInteger.MAX_VALUE;
}
@Override
public booleanisViewFromObject(View arg0,Object arg1) {
returnarg0 == arg1;
}
@Override
public voiddestroyItem(View container, intposition,Object object) {
Share.d("TipsPagerAdapter,destroyItem is called? "+ position);
((ViewPager) container).removeView(listViews.get(position %listViews.size()));
}
@Override
publicCharSequencegetPageTitle(intposition) {
return super.getPageTitle(position);
}
@Override
publicObjectinstantiateItem(View container, intposition) {
Share.d("TipsPagerAdapter, instantiateItem is called "+ position);
try{
((ViewPager) container).addView(
listViews.get(position %listViews.size()),0);
}catch(Exception e) {
}
// ((ViewPager) container).addView(listViews.get(position);
// return listViews.get(position);
Share.d("instantiateItem>>>>>>"+ position %listViews.size());
returnlistViews.get(position %listViews.size());
}
}
好了現(xiàn)在就是直接setadapter就行了枉证,然后寫個(gè)線程循環(huán)跳
adapter=newTTMyPagerAdapters(mList, this);
mPager.setAdapter(adapter);
mPager.setCurrentItem(position);
position是初始滑動(dòng)值,凈量設(shè)置越大越好毡鉴,一般滑不到頭
private voidinitAdapter() {
Share.d("mlist"+mList.size());
//
//TODO Auto-generated method stub
//TODO Auto-generated catch block
change=newThread(newRunnable() {
@Override
public voidrun() {
//TODO Auto-generated method stub
while(true) {
handler.sendEmptyMessage(0);
try{
Thread.sleep(5000);
}catch(InterruptedException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
change.start();
}
@SuppressLint("HandlerLeak")
privateHandlerhandler=newHandler() {
@Override
public voidhandleMessage(Message msg) {
super.handleMessage(msg);
switch(msg.what) {
case0:
position++;
mPager.setCurrentItem(position);
break;
default:
break;
}
}
};
好了現(xiàn)在可沒有結(jié)束猪瞬,你會(huì)發(fā)現(xiàn)list的集合數(shù)小于3的時(shí)候又空白頁(yè)出現(xiàn)陈瘦,但是一張的時(shí)候你又不想讓他滾動(dòng)潮售,怎么辦酥诽?主要是數(shù)據(jù)太短銷毀的時(shí)候有bug肮帐,要是list多了那就無(wú)所謂了,所以怎么辦呢托修?其中一個(gè)辦法睦刃,可以把小于3的list通過(guò)一個(gè)for循環(huán)構(gòu)造出大于他不就OK了仗处,所以那就開干婆誓,循環(huán)添加吧也颤!總結(jié)這個(gè)問(wèn)題就是數(shù)據(jù)一條的時(shí)候翅娶,和2/3條的時(shí)候和多于3條的時(shí)候情況不一樣好唯,分別處理骑篙,我的做法是先在判斷集合以2為界限判斷森书,實(shí)驗(yàn)多次就是2的時(shí)候容易空白凛膏,所以區(qū)分是2和不是的時(shí)候猖毫,是2的話讓他for循環(huán)添加兩次進(jìn)去數(shù)據(jù)變成4就好了,不是2的正常執(zhí)行趁蕊,但是不是2的里邊包括1個(gè)的時(shí)候介衔,那么就在setadapter的時(shí)候處理,區(qū)分新的list是1還是大于3的骂因,這樣問(wèn)題就解決了炎咖,下邊附上全部代碼!
packagecom.example.administrator.student.ui;
importandroid.annotation.SuppressLint;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.content.res.ColorStateList;
importandroid.content.res.Resources;
importandroid.os.Bundle;
importandroid.os.Handler;
importandroid.os.Message;
importandroid.support.v4.view.ViewPager;
importandroid.util.TypedValue;
importandroid.view.MotionEvent;
importandroid.view.View;
importandroid.widget.ImageView;
importandroid.widget.RelativeLayout;
importandroid.widget.TextView;
importcom.example.administrator.student.R;
importcom.example.administrator.student.adapter.TMyPagerAdapters;
importcom.example.administrator.student.adapter.TTMyPagerAdapters;
importcom.example.administrator.student.bean.Main_Data;
importcom.example.administrator.student.utils.Share;
importjava.util.ArrayList;
importjava.util.List;
/**
* Created by Administrator on 2017/10/16.
*/
public classTTestViewPagersActivityextendsActivity {
privateViewPagermPager;
privateListmList;
privateListtsfbBeans=newArrayList();
privateTTMyPagerAdaptersadapter;
privateListlist;
private intposition=50000;
privateThreadchange;
privateRelativeLayoutrootlayout;
@Override
public voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);
mPager= (ViewPager) findViewById(R.id.main_viewpager);
//返回
ImageView back = (ImageView) findViewById(R.id.back);
back.setOnClickListener(newView.OnClickListener() {
@Override
public voidonClick(View view) {
finish();
}
});
Intent intent = getIntent();
String message = intent.getStringExtra("data");
//解析數(shù)據(jù)
//? ? ? ? if (message.length() > 0) {
//? ? ? ? ? ? Gson gson = new Gson();
//? ? ? ? ? ? Main_Data main_data = gson.fromJson(message, new TypeToken() {
//? ? ? ? ? ? }.getType());
//? ? ? ? ? ? tsfbBeans = main_data.getTsfb();
//? ? ? ? }
//構(gòu)造list集合
list=newArrayList();
list.add(R.mipmap.image1);
list.add(R.mipmap.image2);
list.add(R.mipmap.image3);
//? ? ? ? list.add(R.mipmap.image4);
mList=newArrayList();
initView();
}
private voidinitView() {
if(list.size() ==2) {
//如果數(shù)據(jù)是2寒波,就添加兩個(gè)數(shù)組以避免空白頁(yè)
for(intm =0;m <2;m++) {
initValue();
}
}else{
//如果是一個(gè)數(shù)據(jù)那就添加一個(gè)
initValue();
}
adapter=newTTMyPagerAdapters(mList, this);
mPager.setAdapter(adapter);
if(mList.size() >1) {
mPager.setCurrentItem(position);
initAdapter();
}
//? ? ? ? if (mList.size() < 2) {
//
//? ? ? ? } else if (mList.size() == 2) {
//
//? ? ? ? ? ? mPager.setCurrentItem(position + 1);
//? ? ? ? ? ? initAdapter();
//? ? ? ? } else {
//? ? ? ? ? ? mPager.setCurrentItem(position);
//? ? ? ? ? ? initAdapter();
//? ? ? ? }
//mPager.setCurrentItem(count);
mPager.setOnPageChangeListener(listener);
mPager.setOnTouchListener(newView.OnTouchListener() {
@Override
public booleanonTouch(View view,MotionEvent motionEvent) {
return true;
}
});
}
private voidinitValue() {
for(inti =0;i
rootlayout=newRelativeLayout(this);
rootlayout.setLayoutParams(newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
rootlayout.setId(0);
ImageView imageView =newImageView(this);
RelativeLayout.LayoutParams image_Params =newRelativeLayout.LayoutParams(
dip2px(250),dip2px(192));
image_Params.setMargins(dip2px(5),0,dip2px(5),dip2px(5));
imageView.setLayoutParams(image_Params);
imageView.setImageResource(list.get(i));
//Picasso.with(ViewPagersActivity.this).load(tsfbBeans.get(i).getBook_pic()).error(R.mipmap.image1).into(imageView);
imageView.setId(1);
//字體顏色
Resources resource = (Resources) getBaseContext().getResources();
ColorStateList csl = (ColorStateList) resource.getColorStateList(R.color.book_text);
TextView text_Name =newTextView(this);
RelativeLayout.LayoutParams text_Name_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Name_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_Name_Params.addRule(RelativeLayout.ALIGN_TOP,imageView.getId());
text_Name_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_Name.setLayoutParams(text_Name_Params);
text_Name.setText("圖書描述:");
//text_Name.setText(tsfbBeans.get(i).getBook_name() + ":");
text_Name.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_Name.setTextColor(csl);
text_Name.setId(2);
TextView text_Email =newTextView(this);
RelativeLayout.LayoutParams text_Email_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Email_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_Email_Params.addRule(RelativeLayout.BELOW,text_Name.getId());
text_Email_Params.setMargins(dip2px(10),dip2px(5),dip2px(10),0);
text_Email.setLayoutParams(text_Email_Params);
text_Email.setText("《詩(shī)經(jīng)》是中國(guó)古代詩(shī)歌開端乘盼,最早的一部詩(shī)歌總集俄烁,收集了西周初年至春秋中葉(前11世紀(jì)至前6世紀(jì))的詩(shī)歌绸栅,共311篇,其中6篇為笙詩(shī)页屠,即只有標(biāo)題粹胯,沒有內(nèi)容,稱為笙詩(shī)六篇");
//text_Email.setText(tsfbBeans.get(i).getBook_description());
text_Email.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);
text_Email.setId(3);
TextView text_author =newTextView(this);
RelativeLayout.LayoutParams text_author_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_author_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_author_Params.addRule(RelativeLayout.BELOW,text_Email.getId());
text_author_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_author.setLayoutParams(text_author_Params);
text_author.setText("圖書作者:");
//text_author.setText("圖書作者:" + tsfbBeans.get(i).getBook_author());
text_author.setTextColor(csl);
text_author.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_author.setId(4);
TextView text_place =newTextView(this);
RelativeLayout.LayoutParams text_place_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_place_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_place_Params.addRule(RelativeLayout.BELOW,text_author.getId());
text_place_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_place.setLayoutParams(text_place_Params);
text_place.setText("出版社:");
//text_place.setText("出版社:" + tsfbBeans.get(i).getBook_publishing());
text_place.setTextColor(csl);
text_place.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_place.setId(5);
TextView text_data =newTextView(this);
RelativeLayout.LayoutParams text_data_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_data_Params.addRule(RelativeLayout.RIGHT_OF,imageView.getId());
text_data_Params.addRule(RelativeLayout.BELOW,text_place.getId());
text_data_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_data.setLayoutParams(text_data_Params);
text_data.setText("出版日期:");
// text_data.setText("出版日期:" + tsfbBeans.get(i).getBook_publication_date());
text_data.setTextColor(csl);
text_data.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_data.setId(6);
TextView text_description_name =newTextView(this);
RelativeLayout.LayoutParams text_DescriptionName_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_DescriptionName_Params.addRule(RelativeLayout.BELOW,imageView.getId());
//text_Name_Params.addRule(RelativeLayout.ALIGN_TOP, imageView.getId());
text_DescriptionName_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_description_name.setLayoutParams(text_DescriptionName_Params);
text_description_name.setText("圖書簡(jiǎn)介:");
text_description_name.setTextColor(csl);
text_description_name.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
text_description_name.setId(7);
TextView text_description =newTextView(this);
RelativeLayout.LayoutParams text_Description_Params =newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
text_Description_Params.addRule(RelativeLayout.BELOW,text_description_name.getId());
//text_Name_Params.addRule(RelativeLayout.ALIGN_TOP, imageView.getId());
text_Description_Params.setMargins(dip2px(10),dip2px(5),0,0);
text_description.setLayoutParams(text_Description_Params);
text_description.setText("111");
//text_description.setText(tsfbBeans.get(i).getBook_abstract());
text_description.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);
text_description.setId(8);
rootlayout.addView(imageView,image_Params);
rootlayout.addView(text_Name,text_Name_Params);
rootlayout.addView(text_Email,text_Email_Params);
rootlayout.addView(text_description,text_Description_Params);
rootlayout.addView(text_author,text_author_Params);
rootlayout.addView(text_place,text_place_Params);
rootlayout.addView(text_data,text_data_Params);
rootlayout.addView(text_description_name,text_DescriptionName_Params);
//setContentView(rootlayout);
mList.add(rootlayout);
}
}
ViewPager.OnPageChangeListenerlistener=newViewPager.OnPageChangeListener() {
@Override
public voidonPageSelected(intarg0) {
//TODO Auto-generated method stub
//LogUtil.e("當(dāng)前頁(yè)面索引:" + arg0);
}
@Override
public voidonPageScrolled(intarg0, floatarg1, intarg2) {
//TODO Auto-generated method stub
}
@Override
public voidonPageScrollStateChanged(intarg0) {
//TODO Auto-generated method stub
}
};
private voidinitAdapter() {
Share.d("mlist"+mList.size());
//
//TODO Auto-generated method stub
//TODO Auto-generated catch block
change=newThread(newRunnable() {
@Override
public voidrun() {
//TODO Auto-generated method stub
while(true) {
handler.sendEmptyMessage(0);
try{
Thread.sleep(5000);
}catch(InterruptedException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
change.start();
}
@SuppressLint("HandlerLeak")
privateHandlerhandler=newHandler() {
@Override
public voidhandleMessage(Message msg) {
super.handleMessage(msg);
switch(msg.what) {
case0:
position++;
mPager.setCurrentItem(position);
break;
default:
break;
}
}
};
public intdip2px(floatdpValue) {
final floatscale =this.getResources().getDisplayMetrics().density;
return(int) (dpValue * scale +0.5f);
}
@Override
protected voidonDestroy() {
super.onDestroy();
}
}