2

自分のlitView内部に問題がありますviewFlipper

    // GestureDetector
class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        try {
            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
                return false;
            // Right to left swipe
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                IconManager.INSTANCE.leftSwipe();
                vf.setInAnimation(slideLeftIn);
                vf.setOutAnimation(slideLeftOut);
                vf.showNext();
                System.out.println("SWIIINGG!!");
                // Left to right swipe
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                IconManager.INSTANCE.rightSwipe();
                vf.setInAnimation(slideRightIn);
                vf.setOutAnimation(slideRightOut);
                vf.showPrevious();
            }
        } catch (Exception e) {
            // nothing
        }
        return false;
    }
    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        Log.e("Item Click","Item Click");

        Intent intentAgenda = new Intent (Activity_Main.this, AgendaSelected.class);
        //intentAgenda.putExtra("LECTURE_NAME", homeAgendaListAdapter.getItemId(3));
        startActivity(intentAgenda);
        return super.onSingleTapConfirmed(e);
    }
}

このコードを使用すると、フリッパーのビュー間をめくり、さまざまなフリップ内のリストをスクロールできます。ただし、これによりアプリ全体がクリック可能になります。私singleTapが空白の表面にいても、クリックを登録し、私をIntent intentAgenda = new Intent送りたい場所に送ります。listViewこれは、 !内のアイテムをタップした場合にのみ発生するはずです。

特定のリストのリスナーが「リストの」だけをリッスンし、アプリ全体をリッスンしないようにするにはどうすればよいですか?問題は内にあるとpublic boolean onSingleTapConfirmed思いますが、見えません。

4

2 に答える 2

1

リストを含むViewFlipperは同じgestureListenerを持っているため、タップされたviewflipper内のすべてがonSingleTapConfirmed()メソッドをトリガーします。タップのみを処理するために別のgesturelistnerにもリストを登録してみてください:)問題はないように感じますこのコードブロックではなく、gestureListnersなどが設定されている場所です。

于 2011-02-18T13:04:06.047 に答える
1

I have not tried the above but one solution that actually work is to create a new OnItemClickListener and then setOnItemClickListener(your item click listener) on your lists. That would be to not use single tap in your case but just create a new on itemclick listener like this but more stylish:

    list.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            Intent intentAgenda = new Intent (Activity_Main.this, AgendaSelected.class);
            //      //          intentAgenda.putExtra("LECTURE_NAME", homeAgendaListAdapter.getItemId(3));
            startActivity(intentAgenda);
        }
    });

If you want to create more lists you can create a new item click listener and just point every list to it.

于 2011-02-18T13:30:26.470 に答える