如何在这两种方法中获得自定义列表视图的位置?

时间:2014-02-07 19:03:39

标签: android-listview swipe-gesture

SwipeListViewTouchListener touchListener = new SwipeListViewTouchListener(listview, new SwipeListViewTouchListener.OnSwipeCallback() {
    private int position;

    @
    Override
    public void onSwipeLeft(ListView listView, int[] reverseSortedPositions) {
        String telefonoempresa = choferes.get(position).getTelefonoempresa();
        if (telefonoempresa.contains("----------")) {
            Toast.makeText(getApplicationContext(), "TELEFONO NO DISPONIBLE", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "RED LAR" + telefonoempresa, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:" + telefonoempresa));
            startActivity(intent);
        }

    }

    @
    Override
    public void onSwipeRight(ListView listView, int[] reverseSortedPositions) {

        String telefonoparticular = choferes.get(position).getTelefonoparticular();
        if (telefonoparticular.contains("----------")) {
            Toast.makeText(getApplicationContext(), "TELEFONO NO DISPONIBLE", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "TELEFONO PARTICULAR" + telefonoparticular, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:" + telefonoparticular));
            startActivity(intent);
        }

    }
}, true, false);

listview.setOnTouchListener(touchListener);

0 个答案:

没有答案