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

Jesse's Trading System (half-year course) with instructions + video course

Course Catalog Chapter 1 Lesson 1 2021 Daily Limi...

Let’s talk about 5 aspects: How to do brand cross-border marketing?

Cross-border marketing is the process of combinin...

Android 13 new features and adaptation development guide

Part 01 Feature Updates 1.1 Application icons sup...

Ten marketing trends for 2022

At the end of 2019, there was a very popular joke...

The Nobel Prize Legend of "Japanese Forrest Gump"

This is the first Chinese popular science article...

Hanjia Army 2021 First Quarter Practical Sharp Knife Class 8 Documents

Brief introduction to the document resources of H...

1 formula and 2 dimensions to increase the number of likes for short videos!

The pictures below show two identical videos, whi...