ElasticListView


Source link: https://github.com/eschao/android-ElasticListView

ElasticListView

ElasticListView extends android ListView and allows you pull down from the top of ListView to update data and pull up from the bottom of ListView to load data.

Preview

Installation

Gradle

Add it to your build.gradle with:

allprojects {

  repositories {

maven {
 url "https://jitpack.io" 
}

  
}
 
}

and:

dependencies {

  compile 'com.github.eschao:android-ElasticListView:v1.0' 
}

Usage

  1. Use it in layout like android ListView. ElasticListView supports all attributes of android ListView

    Example:

    
      <com.eschao.android.widget.elasticlistview.ElasticListView
    
     android:layout_width="match_parent"
    
     android:layout_height="match_parent"
    
     android:paddingLeft="5dp"
    
     android:paddingRight="5dp"
    
     android:background="@null"
    
     android:cacheColorHint="#00000000"
    
     android:listSelector="#00000000"
    
     android:dividerHeight="1px"
    
     android:scrollbars="none"
    
     android:id="@+id/listview"
    
     android:overScrollMode="never"
    
     android:fadingEdge="none"
    
    >
  2. Use it in java codes

    Example:

    
      mListAdapter = new MyListAdapter(this);
    
    mListView = (ElasticListView)findViewById(R.id.listview);
    
    mListView.setHorizontalFadingEdgeEnabled(true);
    
    mListView.setAdapter(mListAdapter);
    
    mListView.enableLoadFooter(true)
    
    .getLoadFooter().setLoadAction(LoadAction.RELEASE_TO_LOAD);
    
    mListView.setOnUpdateListener(this)
    
    .setOnLoadListener(this);
    
    mListView.requestUpdate();
    
  3. Your class should implement OnUpdateListener and OnLoadListener to complete update and load actions

    Example:

     public class MainActivity extends AppCompatActivity
    
    implements OnUpdateListener, OnLoadListener {
    
    @Override
    
    public void onUpdate() {
    
     // do update action
    
    }
    
    @Override
    
    public void onLoad() {
    
     // do load action
    
    }
    
  4. Noramlly, update and load actions should be run in a separate thread, when these actions are done, you should call the below APIs to notify ElasticListView to change UI accordingly.

    Example:

     // Notify update is done
      mListView.notifyUpdated();
    
     // Notify load is done
      mListView.notifyLoaded();
    
  5. You can enable/disable update and load functions. By default, the update function is enabled and load function is disabled.

    Example:

     // Enable/disable update function
      mListView.enableUpdateHeader(true);
     // or false to disable
    
     // Enable/disable load function
      mListView.enableLoadHeader(true);
     // or false to disable
  6. If you added some header views in ElasticListview and now you want to enable update function again, you need to follow the below steps:

  • Remove all header views
  • Enable update function
  • Add all header views back

The intention of these steps is to assure the update header is at the first position.

  1. You can customize the update header view and load footer view

    Example:

     // Set your own content view of update header and also need to
      // set your update state listener to change UI for different update state
      mListView.getUpdateHeader()
    
      .setContentView(view, true)
    
      .setOnUpdateStateListener(stateListener);
    
    // Set your own content view of load footer and also need to
      // set your load state listener to change UI for different load state
      mListView.getLoadFooter()
    
      .setContentView(view, true)
    
      .setOnLoadStateListener(stateListener);
    
  2. There are three load action types, the default is AUTO_LOAD

  • AUTO_LOAD: when the load footer appears, the onLoad() will be called

  • RELEASE_TO_LOAD: when the load footer fully appears and touch is release, the onLoad() will be called

  • CLICK_TO_LOAD: when the load footer fully appears and user click it, the onLoad() will be called

    Example:

     mListView.getLoadFooter()
    
      .setLoadAction(LoadAction.CLICK_TO_LOAD);
    

License

This project is licensed under the Apache License Version 2.0

Resources

An anti-bikeshedding Kotlin linter with built-in formatter.

ProgressBar with Material Design.

An Android Library to securely read and write encrypted values to your SharedPreferences.

An Android library for drawing gauges on Canvas.

This is a simple download task for Gradle. It displays progress information just as Gradle does when it retrieves an artifact from a repository.

Android library to crop images by moving & scaling image.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes