wdullaer / swipeactionadapter Goto Github PK
View Code? Open in Web Editor NEWThe Mailbox-like Swipe gesture library for Android
License: Apache License 2.0
The Mailbox-like Swipe gesture library for Android
License: Apache License 2.0
this is my code
package com.my.package;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.widget.SimpleCursorAdapter;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FilterQueryProvider;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Toast;
import com.wdullaer.swipeactionadapter.SwipeActionAdapter;
import com.wdullaer.swipeactionadapter.SwipeDirection;
public class MainActivity extends AppCompatActivity {
private BottomSheetDialog bottomSheetDialog;
private SimpleCursorAdapter mycursoradapter;
private ListView mylist;
private DataBaseAdapter myDB;
SwipeActionAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bottomSheetDialog = new BottomSheetDialog(this);
View bottomsheetview = getLayoutInflater().inflate(R.layout.addbottomsheet, null);
bottomSheetDialog.setContentView(bottomsheetview);
LinearLayout addnewbtn = (LinearLayout) bottomSheetDialog.findViewById(R.id.addnewbtn);
LinearLayout addexistbtn = (LinearLayout) bottomSheetDialog.findViewById(R.id.addexistbtn);
addnewbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, AddNewContact.class));
bottomSheetDialog.dismiss();
}
});
addexistbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowToast("add exist");
}
});
openDB();
populateListView();
mAdapter.setSwipeActionListener(new SwipeActionAdapter.SwipeActionListener() {
@Override
public boolean hasActions(int i, SwipeDirection swipeDirection) {
if (swipeDirection.isLeft())
return true; // Change this to false to disable left swipes
if (swipeDirection.isRight()) return true;
return false;
}
@Override
public boolean shouldDismiss(int i, SwipeDirection swipeDirection) {
// Only dismiss an item when swiping normal left
return false; //swipeDirection == swipeDirection.DIRECTION_NORMAL_LEFT;
}
@Override
public void onSwipe(int[] positionList, SwipeDirection[] directionList) {
for (int i = 0; i < positionList.length; i++) {
SwipeDirection direction = directionList[i];
int position = positionList[i];
String dir = "";
switch (direction) {
case DIRECTION_FAR_LEFT:
dir = "Far left";
break;
case DIRECTION_NORMAL_LEFT:
dir = "Left";
break;
case DIRECTION_FAR_RIGHT:
dir = "Far right";
break;
case DIRECTION_NORMAL_RIGHT:
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Test Dialog").setMessage("You swiped right").create().show();
dir = "Right";
break;
}
Toast.makeText(getApplicationContext(), dir + " swipe Action triggered on " + mAdapter.getItem(position), Toast.LENGTH_SHORT).show();
mAdapter.notifyDataSetChanged();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_bar, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.app_bar_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mylist = (ListView) findViewById(R.id.ListConfessioner);
SimpleCursorAdapter filterAdapter = (SimpleCursorAdapter) mylist.getAdapter();
filterAdapter.getFilter().filter(newText.toString());
SwipeActionAdapter mAdapter = new SwipeActionAdapter(filterAdapter);
mAdapter.setListView(mylist);
return false;
}
});
mycursoradapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return myDB.searchname(constraint);
}
});
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//handle presses on the actionbar items
switch (item.getItemId()) {
case R.id.app_bar_search:
return true;
case R.id.btnadd_contact:
bottomSheetDialog.show();
return true;
}
return super.onOptionsItemSelected(item);
}
private void ShowToast(String Text) {
Toast.makeText(getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
}
private void openDB() {
myDB = new DataBaseAdapter(this);
myDB.open();
}
public void populateListView() {
Cursor cursor = myDB.searchname(null);
String[] fromFieldNames = new String[]{myDB.KEY_ROWID, myDB.KEY_NAME, myDB.KEY_DATE};
int[] toviewIDs = new int[]{R.id.textViewpnumber, R.id.textViewpname, R.id.textViewdate};
mycursoradapter = new SimpleCursorAdapter(this, R.layout.item_layout, cursor, fromFieldNames, toviewIDs, 0);
mylist = (ListView) findViewById(R.id.ListConfessioner);
mAdapter = new SwipeActionAdapter(mycursoradapter);
mAdapter.setListView(mylist);
mylist.setAdapter(mAdapter);
mAdapter.addBackground(SwipeDirection.DIRECTION_NORMAL_LEFT, R.layout.row_bg_left);
mAdapter.addBackground(SwipeDirection.DIRECTION_NORMAL_RIGHT, R.layout.row_bg_right);
mylist.setFastScrollEnabled(true);
mylist.setTextFilterEnabled(true);
}
}
``
this is the error
java.lang.ClassCastException: com.wdullaer.swipeactionadapter.SwipeActionAdapter cannot be cast to android.support.v4.widget.SimpleCursorAdapter
how can i solve it
i want to filter my listview and keep the swipe option after filtering
Hello
I have custom ArrayAdapter with button and want to use SwipeActionAdapter for extra features.
Now I have a problem with button because when I click on button on the first item in the ListView the state of item is not changed but when I click on button on another item in the ListView state is changed on the previous item in ListView.
Please let me know if my question is not clear I will provide examples, code and screenshots.
Thx in advance
We have four views, and when we drag right to left, we randomly get a motion:CANCEL, and the swipe aborts. Why? Seems because we are leaving one view, and entering another. Thanks.
Is it possible to set any flag to disable background swipe-directions like hasActions()?
I am stuck on this error/bug and i need help. Adapter still throwing this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.wdullaer.swipeactionadapter.SwipeViewGroup.showBackground(com.wdullaer.swipeactionadapter.SwipeDirection, boolean)' on a null object reference
at com.wdullaer.swipeactionadapter.SwipeActionTouchListener.onTouch(SwipeActionTouchListener.java:419)
at android.view.View.dispatchTouchEvent(View.java:9290)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2547)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent(Activity.java:2765)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:63)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:63)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9514)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5996)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6048)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCall
I copied the code from samples, so this is my code:
final ListView listView = (ListView) findViewById(R.id.listview_predmety);
final SwipeActionAdapter adapter = new SwipeActionAdapter(new Adapter(getApplicationContext()));
adapter.setListView(listView);
listView.setAdapter(new Adapter(getApplicationContext())); /*Adapter shown below*/
adapter.addBackground(SwipeDirection.DIRECTION_NORMAL_LEFT, R.layout.rowbg_predmety_left)
.addBackground(SwipeDirection.DIRECTION_NORMAL_RIGHT, R.layout.rowbg_predmety_right);
adapter.setFarSwipeFraction(1);
adapter.setSwipeActionListener(new SwipeActionAdapter.SwipeActionListener() {
@Override
public boolean hasActions(int position, SwipeDirection direction){
if(direction.isLeft()) return true; // Change this to false to disable left swipes
if(direction.isRight()) return true;
return false;
}
@Override
public boolean shouldDismiss(int position, SwipeDirection direction){
// Only dismiss an item when swiping normal left
return direction == SwipeDirection.DIRECTION_NORMAL_LEFT;
}
@Override
public void onSwipe(int[] positionList, SwipeDirection[] directionList){
for(int i=0;i<positionList.length;i++) {
SwipeDirection direction = directionList[i];
int position = positionList[i];
String dir = "";
if(direction.equals(SwipeDirection.DIRECTION_NORMAL_LEFT)){
dir = "Left";
} else if(direction.equals(SwipeDirection.DIRECTION_NORMAL_RIGHT)){
AlertDialog.Builder builder = new AlertDialog.Builder(PredmetyActivity.this);
builder.setTitle("Test Dialog").setMessage("You swiped right").create().show();
dir = "Right";
}
try {
String s = listView.getItemAtPosition(position).toString();
Log.d(TAG, "onSwipe: " + s);
} catch (NullPointerException e){
e.printStackTrace();
}
Toast.makeText(
getApplicationContext(),
dir + " swipe Action triggered on " + position,
Toast.LENGTH_SHORT
).show();
adapter.notifyDataSetChanged();
}
}
});
Adapter:
private class Adapter extends BaseAdapter{
private final Context context;
private final LayoutInflater inflater;
public Adapter(Context context) {
this.context = context;;
inflater = (LayoutInflater)context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
Cursor cursor = GlobalValues.getDatabase(getApplicationContext()).getData("select count(*) from Subjects");
cursor.moveToFirst();
String count = cursor.getString(0);
return Integer.parseInt(count);
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.activity_listview_row, null);
Cursor cursor = GlobalValues.getDatabase(context).getData("select Name, BasicImage, ProImage from Subjects");
cursor.moveToPosition(i);
ImageView image = (ImageView) layout.findViewById(R.id.image);
if(cursor.getString(2) != null)
image.setImageResource(getResources().getIdentifier(cursor.getString(2).replace(".png", ""), "drawable", context.getPackageName()));
else image.setImageResource(android.R.color.transparent);
TextView textView = (TextView) layout.findViewById(R.id.text);
textView.setText(cursor.getString(0));
return layout;
}
}`
Please someone help me
I'm using the ListView.CHOICE_MODE_MULTIPLE_MODAL with AbsListView.MultiChoiceModeListener.
It works great, the items on the listview get checked on LongClick.
But when using it with the SwipeActionAdapter, the views don't change to the checked state although the onItemCheckedStateChanged is fired.
Hi,
I really like this adapter but I have an issue with my custom adapter. What i wanna do is every swipe it juts increment the txtNumber (TextView) on current selected items. But what happened is some of the items also incrementing. attached is my current codes:
public void onSwipe(int[] positionList, int[] directionList, ListView listView) {
TextView selectedText;
for(int i=0;i<positionList.length;i++) {
int direction = directionList[i];
int position = positionList[i];
switch (direction) {
case SwipeDirections.DIRECTION_FAR_LEFT:
selectedText = (TextView) getViewByPosition(position, listView).findViewById(R.id.txtNumber);
selectedText.setText(String.valueOf(Integer.parseInt(selectedText.getText().toString()) + 1));
break;
case SwipeDirections.DIRECTION_FAR_RIGHT:
selectedText = (TextView) getViewByPosition(position,listView).findViewById(R.id.txtNumber);
if (Integer.parseInt(selectedText.getText().toString()) != 0) {
selectedText.setText(String.valueOf(Integer.parseInt(selectedText.getText().toString()) - 1));
}
break;
default: break;
}
mAdapter.notifyDataSetChanged();
}
}
public View getViewByPosition(int pos, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (pos < firstListItemPosition || pos > lastListItemPosition ) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
public void convertStringToArray(String data) {
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(data);
} catch (JSONException e) {
e.printStackTrace();
}
String[] strArr = new String[jsonArray.length()];
ArrayList<String> arrayList = new ArrayList<String>();
for (int i = 0; i < jsonArray.length(); i++) {
try {
strArr[i] = jsonArray.getJSONObject(i).getString("name");
arrayList.add(jsonArray.getString(i));
System.out.println(strArr[i]);
ArrayAdapter<String> stringAdapter = new ArrayAdapter<String>(
this,
R.layout.foods_extra,
R.id.txtName,
new ArrayList<String>(Arrays.asList(strArr))
);
mAdapter = new SwipeActionAdapter(stringAdapter);
mAdapter.setSwipeActionListener(this).setListView(getListView());
mAdapter.addBackground(SwipeDirections.DIRECTION_FAR_LEFT, R.layout.row_bg_left)
.addBackground(SwipeDirections.DIRECTION_FAR_RIGHT, R.layout.row_bg_right);
setListAdapter(mAdapter);
stringAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Thanks, please help.
Can I create list where items can have different background?
Hello, the Item in my ListView is segmented into some parts, and each part is clickable.
When the child is clickable, the touch event will be intercept by child, so the ListView Item can't be swiped.
However,the ListView still can be scrolled as expected.
My Question is how can I make ListView Item be swiped as normal , when it is segmented into some clickable views?
Thank you for help.
Hi,
I'm using your library in a SwipeRefreshLayout (to allow for pull down refresh mechanism).
Unfortunately it seems that the pullToRefresh feature hijacks touch events.
For example, if you have the following layout;
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listViewItems"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
And use your SwipeActionAdapter on the ListView listViewItems, when you swipe left for a little bit; then swipe down a little bit (not fully engaging the pullToRefresh in the SwipeRefreshLayout), you can no longer continue to swipe within the item you started swiping in.
The only solution (that I'm aware of) is to disable the swipeRefreshLayout if the user started started swiping, to prevent it from hijacking the touch events in SwipeActionAdapter.
This is currently not possible as there are no events available to indicate when a user started and stopped swiping an item.
This would allow me to do;
@Override
public void onSwipeStarted(ListView listView, int position, SwipeDirection direction) {
swipeRefresh.setEnabled(false);
}
@Override
public void onSwipeEnded(ListView listView, int position, SwipeDirection direction) {
swipeRefresh.setEnabled(true);
}
Which fixes the problem.
Regards,
Jeroen
Hi dude ,
Iam new to android , and i need help , i need to make actions on the layouts that appear on swipe , how ???
There is no way to stop swipe animations from running. Looks like SwipeActionTouchListener controls animations and only starts them, never stopping them.
Example use case:
When onPause is called, clients should be able to stop all animations (standard practice). 2 issues arise:
I have removed the listener in onPause so that callbacks won't be executed (solves 2), however, it would be great to be able to stop the animations from running.
If I remove an element from the list, the element that is now at the element's position inherits the height of the removed element.
This is because SwipeActionAdapter.getView()
is too aggressive when it recycles it's backgrounds and does not resize the background to fit the new foreground.
I think the right way to do this is to check if contentView
's height has changed and if so re-inflate the background.
A work around is to wrap SwipeActionAdapter
with a NonRecyclingAdapter
such as:
private static class NonRecyclingAdapter extends DecoratorAdapter {
public NonRecyclingAdapter(BaseAdapter baseAdapter) {
super(baseAdapter);
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
return super.getView(position, null, parent);
}
}
Have you tried to use NineOldAndroid to make you libary backward compatible to lower than 4.0.0 ?
I've tried but it generates a bunch of glitches on old terminals :/
This is a feature request; To allow swipe in only one direction for Rows (or both depending on the requirements). This would mean replacing hasActions
with two methods: swipesLeft
and swipesRight
:
// Example Implementation
@Override
public boolean swipesLeft(int position) {
// Swipe Left for only Odd Rows
return position % 2 == 1;
}
@Override
public boolean swipesRight(int position) {
// Swipe Right for only Even Rows
return position % 2 == 0;
}
I'm unable to implement SwipeActionAdapter
on a Non-ListActivity (just a simple ActionBarActivity) with an independent ListView. The code builds and runs, but the rows do not slide on swiping. Here's what my onCreate
looks like:
public class HomeActivity extends ActionBarActivity {
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
friendList = (ListView) findViewById (R.id.friendsList);
friendAdapter = new FriendListAdapter(this, friends);
swipeAdapter = new SwipeActionAdapter(friendAdapter);
swipeAdapter.setListView(friendList);
friendList.setAdapter(swipeAdapter);
swipeAdapter
.addBackground(SwipeDirections.DIRECTION_NORMAL_LEFT, R.layout.row_bg_green)
.addBackground(SwipeDirections.DIRECTION_NORMAL_RIGHT, R.layout.row_bg_yellow);
// ...
}
// ...
And here's my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/bgColor" >
<!-- Other Views... -->
<LinearLayout
android:orientation="vertical"
android:layout_below="@+id/infoText"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_above="@+id/statusSwitch"
android:layout_marginBottom="10dp" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/friendsList"
android:divider="@null"
android:dividerHeight="0dp"
android:scrollbars="none"/>
</LinearLayout>
</RelativeLayout>
mAdapter = new SwipeActionAdapter(stringAdapter);
mAdapter.addBackground(SwipeDirection.DIRECTION_NORMAL_RIGHT, R.layout.row_bg_right)
.addBackground(SwipeDirection.DIRECTION_NORMAL_LEFT, R.layout.row_bg_left)
.setSwipeActionListener(this)
.setFadeOut(true)
So, While i set .setFadeOut(true), background layout does not show.
It shows only white background.
Waiting for your replay
Thanks,
While i am importing this library in my project. it will give these errors NoClassDefFoundError ,i am using eclipse Mars 1.
i have import library as a JAR.
logTXT.txt
Hi , thanks for the SwipeActionAdapter, the app become more easier to use.
But, as shown in the figure, SwipeActionAdapter 1.4.4 may meet some trouble in showing in Android 4.1 or 4.2.
http://i3.tietuku.com/a07fe2e3f8fcf268.jpg
So, could it be fixed ?
Thank you for good swipe solution! Could you please help me with other event listeners: for my ListView I need your onSwipe method as well as single tap and long tap.
For instance only ListView scrolling works. If I use listview.setOnItemClickListener, swipe one doesnt' work anymore.
I've Horizontal Scroll view inside my every list-item but its scroll is not working. Whenever i try to swipe the horizontal scroll view, list-item swipe actions is called. Would you please tell me how to fix this? or any other alternative to horizontal scroll view?
Unable to customize the view of background. it is always throwing me with null pointer exception.
how to customize with two image views for background.
Hi,
I have used a little bit that library, but I am unable to change the background colour of the listview(ie when it's empty i just have plain white) is there any way doing it, the way it is built with the row_bg.xml layouts for every item?
Thanks
I don't really think I can explain this issue. It's better if I show you:
GIF 1: When swiping back and forth on a row while keeping the
touchPoint
inside the row, it works fine. But when thetouchPoint
goes outside the row, only the last appearing Background Layout is visible.GIF 2: If you bring the
touchPoint
back inside the row while the background layout that was supposed to be visible (but isn't), it suddenly appears.
Your swipe Action adapter takes only base adapter. any way to add custom adapter?
Hello,
I have a simple list view fragment that has 2 different items. First being the "section header" which separates my sections. Second being the actual list item content.
My list item "section header" height is set to wrap content, while I have a defined height (82dp) from the list item content.
I have two corresponding layout items (also at 82dp) that represent whats seen when swiping left and right. That works great.
However I'm something a strange bit of extra space (a couple of pixels) after my "section title" when the "addBackground" is applied to the swipe list view. If I remove it (the code below in particular) it doesn't include that extra space.
Is the issue issue due to the "section header"? I have code implemented so that swipe action does not occur on the section header.
Thanks!
.setSwipeActionListener(vbf)
.addBackground(SwipeDirections.DIRECTION_FAR_LEFT, R.layout.view_venue_beer_mark_blown)
.addBackground(SwipeDirections.DIRECTION_NORMAL_LEFT, R.layout.view_venue_beer_mark_blown)
.addBackground(SwipeDirections.DIRECTION_FAR_RIGHT, R.layout.view_venue_beer_mark_seen)
.addBackground(SwipeDirections.DIRECTION_NORMAL_RIGHT, R.layout.view_venue_beer_mark_seen)
Is possible to implement in the call hasActions also the direction? For example, to make possible swiping only to the right
While creating a custom list for autocompletetextview , is there any way that i can use the Swipe Action Adapter on the list of suggestions that is shown in the autocompletetextview?
Instead of content[] string, I made it as arraylist of string. On far left event, I am deleting that string from the arraylist. The string gets deleted from the arraylist but the view of ListView is not refreshed event after calling notifyDataSetChanged() in both stringAdapter and mAdapter
I use the StickyListheaders (https://github.com/emilsjolander/StickyListHeaders) and wants to add the SwipeActionAdapter.
Does anyone have done this?
The problem is that the "StickyList" needs an "StickyListHeadersAdapter".
My CusrsorAdapter implements the "StickyListHeadersAdapter" and I set it to the "StickyListHeadersListView" without "SwipeActionAdapter".
Now I set the CursorAdapter to the "SwipeActionAdapter" and want to set the "SwipeActionAdapter" to the "StickyListHeadersListView", but this does not work because "SwipeActionAdapter" does not implement "StickyListHeadersAdapter"!
How can I solve this? Or does it not work to use this both?
I have to implement SwipeToDelete while swipe from Right to Left & SwipeToSave while swipe from Left to Right.
But i have to implement this functionality in PullToRefreshListView.
So give me suggestion or upload your library if possible
Thanks
Is it possible to keep the "swiped background" until I swipe back?
For example: I would like to delete the row if I swipe to the right and show some extra information if I'm swiping to the left (until I swipe back). I couldn't find an easy implementation with the current library.
Wouldn't it be make sense to pass this as an additional argument in the mAdapter.addBackground(...) function?
Thanks
This is a great library. Are there any plans to support RecyclerView?
Hi, another problem I was facing, and I am not sure if it is possible to be changed the way it is constructed, is if we can have multiple(different) row layouts according the the listview items.
For example , just changing the background colour of an image of a row layout, according to a listview variable (as the adapter wraps the listview).
Thanks
I want to use the icons in the list-items background which display on swipe. I try to add the image in the background layout file but the image repeatedly draws so many times. Please tell me how can i add a icon with background color like in google inbox exactly? Thanks in advance!
Hi,
I'm trying to use swipe adapter with StickyListHeaders.
https://github.com/emilsjolander/StickyListHeaders
I think I'm close to a solution, however when I swipe on a row I get the following immediate exception. It does however hit the "hasActions" method
08-02 11:33:07.364 1655-1655/com.slaptap.tappedin E/InputEventReceiver﹕ Exception dispatching input event.
08-02 11:33:07.364 1655-1655/com.slaptap.tappedin E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
08-02 11:33:07.380 1655-1655/com.slaptap.tappedin E/MessageQueue-JNI﹕ java.lang.NullPointerException
at com.wdullaer.swipeactionadapter.SwipeActionTouchListener.onTouch(SwipeActionTouchListener.java:419)
at android.view.View.dispatchTouchEvent(View.java:7701)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
I am setting things up like so inside of a Fragment
mAdapter = new VenueBeerListAdapter(getActivity(), data);
listView.setAdapter(mAdapter);
swipeAdapter = new SwipeActionAdapter(mAdapter);
swipeAdapter.setListView(listView.getWrappedList())
.setSwipeActionListener(vbf)
.addBackground(SwipeDirections.DIRECTION_FAR_LEFT, R.layout.view_venue_beer_mark_blown)
.addBackground(SwipeDirections.DIRECTION_NORMAL_LEFT, R.layout.view_venue_beer_mark_blown)
.addBackground(SwipeDirections.DIRECTION_FAR_RIGHT, R.layout.view_venue_beer_mark_seen)
.addBackground(SwipeDirections.DIRECTION_NORMAL_RIGHT, R.layout.view_venue_beer_mark_seen).notifyDataSetChanged();
Any initial thoughts on what I might be doing wrong? I can provide more info if need.. really appreciate the help :)
Hi, SwipeActionAdapter is fantastic, but I have a problems when ScrollUp the Listview with SwipeRefreshLayout.
Thanks
My dependency not resovlve after upgrading to 2.0.0 gradle sync was successful but in java class it is not resoling all imports of swipeactionAdapter .
I have tried cleaning my project and also tried restart with invalidate cache.
02-23 17:54:32.444 1926 1926 E AndroidRuntime: FATAL EXCEPTION: main
02-23 17:54:32.444 1926 1926 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.View$OnTouchListener.onTouch(android.view.View, android.view.MotionEvent)' on a null object reference
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.wdullaer.swipeactionadapter.SwipeViewGroup.onInterceptTouchEvent(SwipeViewGroup.java:174)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2108)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.app.Activity.dispatchTouchEvent(Activity.java:2771)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.View.dispatchPointerEvent(View.java:9520)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.os.MessageQueue.nativePollOnce(Native Method)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.os.MessageQueue.next(MessageQueue.java:323)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-23 17:54:32.444 1926 1926 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi, Thanks for this adapter. I am using a custom adapter in my project that has autocompletetextbox, edittext and few spinners. As soon as I add this adapter autocomplete and edittext dont work. I can't click on them and change values. looks like listeners aren't responding properly. May be its how its designed. Please suggest.
Hello.
When i use a normal layout, with just a background color my animation is very smooth, but when i add one imageview to the layout i have a animation with lag.
For my listview I have multiselect action mode, with following background selector for item layout
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/md_grey_400"/>
<item android:drawable="@android:color/transparent" />
</selector>
But when I've added SwipeActionAdapter, list item is not styled correctly on click (not become gray). I assume it's because my main layout not activated anymore.
Is there idea how to fix this, I would love to use this library in my project as it very easy to use and it gives what I need. Thanks for any help.
Just what the title says; allow the developer to specify a custom value for the Far
and Normal
thresholds for the SwipeAdapter
Hi,
I am using an ExpandableListView instead of the normal ListView. When wrapping my BaseExpandableListAdapter inside SwipeActionAdapter, its giving an error.
Is there a way to make it work?
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.