如何在swipelistview项目中只向左滑动

how to in swipelistview item only swipe to left

im used this libarary https://github.com/47deg/android-swipelistview in project im want row only swipe to left and not allow swipe rows with wiche other and when clicked row not swipeing and open new Activity

 public class Aragh extends Activity {
        SwipeListView swipelistview;
        ItemAdapter adapter;
        List<ItemRow> itemData;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.aragh);
             swipelistview=(SwipeListView)findViewById(R.id.example_swipe_lv_list); 

                itemData=new ArrayList<ItemRow>();
                adapter=new ItemAdapter(this,R.layout.custom_row,itemData);



                swipelistview.setSwipeListViewListener(new BaseSwipeListViewListener() {
                    @Override
                    public void onOpened(int position, boolean toRight) {
                    }

                    @Override
                    public void onClosed(int position, boolean fromRight) {
                    }

                    @Override
                    public void onListChanged() {
                    }

                    @Override
                    public void onMove(int position, float x) {
                    }

                    @Override
                    public void onStartOpen(int position, int action, boolean right) {
                        Log.d("swipe", String.format("onStartOpen %d - action %d", position, action));
                    }

                    @Override
                    public void onStartClose(int position, boolean right) {
                        Log.d("swipe", String.format("onStartClose %d", position));
                    }

                    @Override
                    public void onClickFrontView(int position) {
                        Log.d("swipe", String.format("onClickFrontView %d", position));


                        swipelistview.openAnimate(position); //when you touch front view it will open


                    }

                    @Override
                    public void onClickBackView(int position) {
                        Log.d("swipe", String.format("onClickBackView %d", position));

                        swipelistview.closeAnimate(position);//when you touch back view it will close
                    }

                    @Override
                    public void onDismiss(int[] reverseSortedPositions) {

                    }

                });

                //These are the swipe listview settings. you can change these
                //setting as your requirement 
                swipelistview.setSwipeMode(SwipeListView.SWIPE_MODE_RIGHT); // there are five swiping modes
                swipelistview.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_DISMISS); //there are four swipe actions 
                swipelistview.setSwipeActionRight(SwipeListView.SWIPE_ACTION_DISMISS);
                swipelistview.setOffsetLeft(convertDpToPixel(0f)); // left side offset
                swipelistview.setOffsetRight(convertDpToPixel(80f)); // right side offset
                swipelistview.setAnimationTime(500); // Animation time
                swipelistview.setSwipeOpenOnLongPress(false); // enable or disable SwipeOpenOnLongPress

                swipelistview.setAdapter(adapter);


                for(int i=0;i<10;i++)
                {
                    itemData.add(new ItemRow("Swipe Item"+i,getResources().getDrawable(R.drawable.ic_launcher) ));

                }

                adapter.notifyDataSetChanged();
            }

            public int convertDpToPixel(float dp) {
                DisplayMetrics metrics = getResources().getDisplayMetrics();
                float px = dp * (metrics.densityDpi / 160f);
                return (int) px;
            }



        }

您只需要在 xml 布局中将 swipe:swipeMode="left" 放在 <....SwipeListView /> 内,以允许仅向左滑动

我建议在 XML 中进行。

在您的 SwipeListView 标签中添加

swipe:swipeMode="left"

它将您的滑动模式锁定在左侧。 你可以选择 - 左/右/两者。