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

At the critical moment, this article may save your life!

One minute with the doctor, the postures are cons...

GSMA: China's 5G vertical industry application cases in 2022

2021 is a critical year for 5G to achieve initial...

How to plan a large event? Here are 6 basic elements

Before planning an event , ask yourself, why do y...

The 237th issue of "Trading Sense Training Camp"

Resource introduction of the 237th issue of "...

How to use Luckin Coffee coupons!

Luckin Coffee ’s coupon marketing can only help i...

User growth operation: How to achieve explosive growth of products?

Due to the epidemic this year, many Internet comp...

Here's why Siri is hard to use, and it's about to be solved

When many people talk about Siri, they often comp...

2019 Spring Festival Information Flow Marketing Analysis Report!

The 2019 Spring Festival is approaching. As we al...

The desert turns into a "lake"! What happened to the Taklimakan Desert?

Produced by: Science Popularization China Author:...

China Mobile A4s review: Extreme simplicity and great experience are king

  [China Mobile Review] With the upgrading of cons...