SwipeMenuListView


Source link: https://github.com/baoyongzhang/SwipeMenuListView

SwipeMenuListView

A swipe menu for ListView.

Demo

Usage

Add dependency

dependencies {

  compile 'com.baoyz.swipemenulistview:library:1.3.0' 
}

Step 1

  • add SwipeMenuListView in layout xml
<com.baoyz.swipemenulistview.SwipeMenuListView

android:id="@+id/listView"

android:layout_width="match_parent"

android:layout_height="match_parent" />

Step 2

  • create a SwipeMenuCreator to add items.
SwipeMenuCreator creator = new SwipeMenuCreator() {

@Override  public void create(SwipeMenu menu) {

// create "open" item
SwipeMenuItem openItem = new SwipeMenuItem(
  getApplicationContext());

// set item background
openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9,
  0xCE)));

// set item width
openItem.setWidth(dp2px(90));

// set item title
openItem.setTitle("Open");

// set item title fontsize
openItem.setTitleSize(18);

// set item title font color
openItem.setTitleColor(Color.WHITE);

// add to menu
menu.addMenuItem(openItem);

 // create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(
  getApplicationContext());

// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
  0x3F, 0x25)));

// set item width
deleteItem.setWidth(dp2px(90));

// set a icon
deleteItem.setIcon(R.drawable.ic_delete);

// add to menu
menu.addMenuItem(deleteItem);
  
}
 
}
;  // set creator listView.setMenuCreator(creator);

Step 3

  • listener item click event
listView.setOnMenuItemClickListener(new OnMenuItemClickListener() {
  @Override  public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {

switch (index) {

case 0:
 // open
 break;
case 1:
 // delete
 break;

}

// false : close the menu; true : not close the menu
return false;  
}
 
}
);

Swipe directions

 // Right  mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_RIGHT);

 // Left  mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);

Create Different Menu

  • Use the ViewType of adapter
 class AppAdapter extends BaseAdapter {

 ...

@Override
public int getViewTypeCount() {

 // menu type count
 return 2;

}

@Override
public int getItemViewType(int position) {

 // current menu type
 return type;

}

 ...  
}
  • Create different menus depending on the view type
 SwipeMenuCreator creator = new SwipeMenuCreator() {

  @Override
 public void create(SwipeMenu menu) {

  // Create different menus depending on the view type
  switch (menu.getViewType()) {

  case 0:

// create menu of type 0

break;
  case 1:

// create menu of type 1

break;
  ...
  
}

 
}

 
}
;
  • Demo

Other

  • OnSwipeListener
listView.setOnSwipeListener(new OnSwipeListener() {

@Override  public void onSwipeStart(int position) {

// swipe start  
}

 @Override  public void onSwipeEnd(int position) {

// swipe end  
}
 
}
);
  • open menu method for SwipeMenuListView
listView.smoothOpenMenu(position);
  • Open/Close Animation Interpolator
// Close Interpolator listView.setCloseInterpolator(new BounceInterpolator());
 // Open Interpolator listView.setOpenInterpolator(...);

Resources

This is simple watchface constructor demo. It offers customization of the following features:

  • Background colors and images
  • Watch hands
  • Placement of watch hands
  • Ambient mode

An interesting EditText with pretty animation.

React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

AnimatedVectorMorphingTool is a command line tool which generates, for you, all the files needed to animate your VectorDrawable. You just drop your VectorDrawables and it generates all the files needed for your android project in a res folder. You just have to copy paste this folder into your own project and run your application.

Rich Text Editor for Android.

A powerful Recyclerview wrapper for working with Realm as your datastore. It supports the following features out of the box:

  • Custom adapter that automatically refreshes the list when the realm changes and animates the new items in.
  • Empty state
  • Pull-to-refresh
  • Infinite scrolling
  • Section headers

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