Coder Social home page Coder Social logo

dynamicviewpager's Introduction

DynamicViewPager

It’s a convenient library for creating nine-grid view pager.

Feature

  • Specify any row and col count in xml
  • Can be combined with page indicator
  • Less code, easy to use

Screenshot

Drawing

How to use?

Declare DynamicViewPager in your layout xml file. You can set row and col count attribute.

<com.happy.widget.DynamicViewPager
    android:id="@+id/dynamicviewpager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:col="4"
    app:row="3"
    />

Get view and init data item

    int size = 30;
    List<DataItem> dataItemList = new ArrayList<>(size);

    for (int i = 0;i<size;i++){
        DataItem item = new DataItem(""+i,R.drawable.heart,"item "+i);
        dataItemList.add(item);
    }

    mDynamicPagerAdapter = new DynamicPagerAdapter(this,mDynamicViewPager,R.layout.data_root,R.layout.data_item_content,dataItemList);
    mDynamicViewPager.setAdapter(mDynamicPagerAdapter);


}

Detect page item click

  mDynamicViewPager.setPageItemClickListener(new DynamicViewPager.OnPageItemClickListener() {
        @Override
        public void onPageItemClick(int page, int position, String tag, DataItem item) {
            Toast.makeText(MainActivity.this,"You click page: "+page+" position: "+position,Toast.LENGTH_SHORT).show();
        }
    });

Notice

DynamicPageAdapter constructor paramter:

  • R.layout.data_root must have a gridview with id "grid"
  • R.layout.data_item_content must have a imageview with id "image" and a textview with id "text"
  • Because dynamicviewpager use these ids to find according view

Download

Gradle

compile 'com.happy.widget:dynamicviewpager:0.1.0'

Contact

You can reach me by email [email protected]

License:

Apache License, Version 2.0

dynamicviewpager's People

Contributors

nziyouren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.