问题描述
我正在使用一个片段来显示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>
@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;
}
});
从来没有反应。我还将itemtouchhelper与simplecallbacks一起使用,以在回收器视图中注册对项目的单击,效果很好,如果有大量项目,也可以在列表中滚动。因此,这里有一些触摸功能。当我在主要活动中使用onTouchListener时,它工作正常,但将其移至片段时却无法正常工作。
我不确定是否还有其他相关信息,我们将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)