PagerAdapter paging image and text view, can slide left and right

PagerAdapter paging image and text view, can slide left and right

Source code introduction

I have been studying about paging recently, and I found that the official one from Google is more convenient to use. Today, I wrote one or two models to share with you. As for the viewpage I uploaded, I was criticized for not fully understanding it because I didn’t understand it very well. In fact, it was not comprehensive to begin with. I usually just upload some models, and I will definitely not upload the project so easily. I will upload and share with you after I solve any problems I encounter in the project. You can slide left and right.
Source code running screenshot

Source code snippet:

  1. private   void init(){
  2. options = new DisplayImageOptions.Builder()
  3. .showImageOnLoading(R.drawable.image_loading)
  4. .showImageForEmptyUri(R.drawable.image_empty)
  5. .showImageOnFail(R.drawable.image_error)
  6. .cacheInMemory( true )
  7. .cacheOnDisk( true )
  8. .considerExifParams( true )
  9. .bitmapConfig(Bitmap.Config.RGB_565)
  10. .build();
  11. //Load the image resource ID  
  12. myPageTestModels= new ArrayList<mypagetestmodel>();
  13. mImageViews= new ImageView[ 23 ];
  14. MyPageTestModel mTestModel;
  15. for ( int i = 0 ; i < 23 ; i++) {
  16. mTestModel= new MyPageTestModel();
  17. mTestModel.setId(i);
  18. mTestModel.setName( "name" +i);
  19. mTestModel.setUrl( "http://www.amsoft.cn/content/templates/amsoft/images/rand/" +i+ ".jpg" );
  20. myPageTestModels.add(mTestModel);
  21. }
  22.   
  23. //Add dots to the ViewGroup  
  24. tips = new ImageView[myPageTestModels.size()];
  25. for ( int i= 0 ; i<tips.length; i++){= "" imageview= "" imageview( this );= "" imageview.setlayoutparams( new = "" layoutparams( 10 , 10 ));= "" tips[i]= "imageView;"   if (i= "="   0 ){= "" tips[i].setbackgroundresource(r.drawable.page_indicator_focused);= "" } else {= "" tips[i].setbackgroundresource(r.drawable.page_indicator_unfocused);= "" }= "" linearlayout.layoutparams= "" layoutparams= "new" linearlayout.layoutparams( new = "" viewgroup.layoutparams(layoutparams.wrap_content,= "" layoutparams.wrap_content));= "" layoutparams.leftmargin= "5;" layoutparams.rightmargin= "5;" group.addview(imageview,= "" layoutparams);= "" views= "new" arraylist<view= "" >();
  26. //Create the graphic information that needs to be displayed on each page  
  27. for ( int i= 0 ;i<mypagetestmodels.size();i++){ view= "" mpageview= "LayoutInflater.from(MyPageActivity2.this).inflate(R.layout.page_gridview_item,"   } = " " Set adapter = "" viewpager.setadapter( new = " " mypageadapter(mypageactivity2 . this , = "" views) ) ; = " " Set the listener , mainly to set the background of dots = " " viewpager.setonpagechangelistener ( this ) ; = " " Set the default item of viewpager, = "" Set it to 100 times the length, so that you can slide to the left at the beginning = "" viewpager.setcurrentitem((mypagetestmodels.size()) = "" * = ""   100 );= "" }<= "" pre= "" >
  28.                   
  29. </mypagetestmodels.size();i++){></tips.length;></mypagetestmodel>

Source code link: http://download..com/data/1983048

<<:  Google plans to launch new Plaso mobile payment service to challenge Apple

>>:  Zxing scan code example

Recommend

How to achieve "real sales" KOL marketing in 2 steps?

Unilever CMO Keith Weed announced at the recent C...

VR and the Internet of Things will drive future growth of smartphones

On February 26, 2016, research firm Kantar Worldp...

Apple iOS 15 is upgraded but it seems not upgraded

In the early morning of June 8th, Beijing time, t...

Where will the next big battle between Apple and Google be?

July 7, 2019: In recent years, the battle lines b...

Apple submits training plan for operators for new autonomous driving progress

According to Reuters, in a document submitted to ...

Coughing non-stop, use cough patch? Beware of chemical burns

Audit expert: Peng Guoqiu Deputy Chief Physician,...