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

Talk about how to make money using Zhihu traffic

How to make money using Zhihu? This is a topic th...

Satellite photography: What the Earth looks like from space

How about renting or buying a satellite to take p...

Three major processes of Android View drawing

introduce The workflow of View mainly refers to t...

Xiaohongshu’s promotion strategies and methods!

Speaking of Xiaohongshu, what is the first thing ...

How to make information flow video ads more efficient?

Some advertisers have already reaped the benefits...

10 successful tourism scenic spot marketing planning cases

When it comes to tourism marketing , whether it’s...