Skip to content

这是基于Android的一个项目,这个ListView提供左右滑动来删除Item的功能

License

Notifications You must be signed in to change notification settings

Gracker/SlideDelete-ListView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Android:SlideDelete-ListView

This is a special ListView that you can slide to delete it's item .


#Usage 1.add SlideDeleteListView in your layout file

	<yourpackagename.SlideDeleteListView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/listView"
            android:layout_gravity="left|top" />

2.add dependencies in build.gradle

	compile project(':slidedeletelistview')

3.setup SlideDeleteListView in your java code

  • set Adapter
  • set RemoveListener
	mSlideDeleteListView.setRemoveListener(new SlideDeleteListView.RemoveListener() {
            @Override
            public void removeItem(SlideDeleteListView.RemoveDirection direction, int position) {
                Toast.makeText(getContext(), "Item " + position + " has deleted",
                        Toast.LENGTH_SHORT).show();
                        
                //update data
                mListAdapter.updateDataSet(position);
            }
        });
        
	public void updateDataSet(int position) {
    		Log.i("Gracker","update position =" + position);
		arrayList.remove(position);
		notifyDataSetChanged();
}

About

这是基于Android的一个项目,这个ListView提供左右滑动来删除Item的功能

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages