Android 如何在片段中实现触摸事件功能?

Android 如何在片段中实现触摸事件功能?,android,android-fragments,touch,multi-touch,Android,Android Fragments,Touch,Multi Touch,我正在使用一个片段来显示recyclerview。我的目标是拥有多点触控功能,这样就有可能做出捏手势 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:

我正在使用一个片段来显示recyclerview。我的目标是拥有多点触控功能,这样就有可能做出捏手势

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".ScoreboardFragment"
    android:focusable="true"
    android:clickable="true">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/scoreboardView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:clickable="true"
        />
</androidx.constraintlayout.widget.ConstraintLayout>
它从来没有反应过。我还使用带有simplecallbacks的ItemTouchHelper在recycler视图中注册对项目的点击,这很好,如果有大量项目,也可以在列表中滚动。所以这里有一些触摸功能。当我在主活动中使用onTouchListener时,它工作得很好,但当将其移动到片段时,它就不工作了


我不确定是否有更多相关信息,非常感谢您的帮助。

使用Log.d()而不是System.out.println()。或者你可以使用toast“toast.makeText(这个“TEST”,toast.LENGTH_SHORT).show();”我测试了它,但仍然没有发生任何事情
 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView =  inflater.inflate(R.layout.fragment_scoreboard, container, false);
        rootView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event){
                System.out.println("TEST");
                return true;

            }
        });