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

Barnard 68, mistakenly thought to be a black hole, is actually a mass...

Author: Huang Xianghong Duan Yuechu There are man...

iOS 12 wish list: These are the features Apple fans want

As we all know, Apple will release iOS 12 at the ...

$200,000 for a lunch with Tim Cook

[[133526]] Beijing time, May 7 morning news, Appl...

In-depth | How to start new media operations without a budget?

How to start new media operations without a budge...

Successfully launched! All members of Gaofen-3 have assembled!

The reporter learned from the National Space Admi...

How should operations be performed in the three stages of APP development?

The bell of 2017 has rung. As I am about to enter...

Model Y's rival? The B-class pioneer hunting SUV Song L is here!

On August 25, the B-class pioneer hunting SUV BYD...

Tech Neo Technology Salon 15th Special Report - How CDN Makes the Network Smarter

【51CTO.com original article】 [51CTO original arti...

"Teacher, I really didn't perm my hair!" - A desperate cry from a natural curly girl

——Why are some people naturally curly and some no...