我在主片段上有一个TextVIEw(sub_text),另一个是RecyclerVIEw
(rv)包含TextVIEw项.
当我尝试在RecyclerVIEw中选择文本时,我获得了不同数量的项目.
它缺少实现ACTION_PROCESS_TEXT的其他应用程序的选择.
我选择的项目只是部分 – 与stackoverflow上的其他问题不同(例如“android:textIsSelectable=”true” not working for TextView in RecyclerView),其中选择完全缺失或不起作用.
如何使rv的textVIEw中的项与片段的textVIEw相同?
但是,当我尝试从Recycler视图中选择文本时,我得到以下浮动文本选择工具栏
请注意,RV中只有2个可选项?
sub_text的xml是
rv的xml是
ID.support.v7.Widget.RecyclerVIEw androID:ID="@+ID/rv" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" androID:scrollbars="vertical" app:layoutManager="androID.support.v7.Widget.linearlayoutmanager" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" />
rv中textvIEw的xml是
最佳答案Text VIEw need to be enabled,focusable,longClickable and
textIsSelectable
use bellow recycler vIEw code
ID.support.v7.Widget.RecyclerVIEw androID:layout_wIDth="0dp" androID:layout_height="0dp" androID:ID="@+ID/recyclerVIEwRecordList" app:layout_constrainttop_toBottomOf="@+ID/relativeLayoutheader" app:layout_constraintleft_toleftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_totopOf="@+ID/vIEw_bottom" androID:layout_margin="10dp" androID:focusable="true" androID:focusableIntouchMode="true">
use Speedylinearlayoutmanager in code instead of xml
Speedylinearlayoutmanager linearlayoutmanager = new Speedylinearlayoutmanager(this);linearlayoutmanager.setorIEntation(linearlayoutmanager.VERTICAL);myRecyclerVIEwList.setLayoutManager(linearlayoutmanager);RecordAdapter myCustomerAdapter = new RecordAdapter(this,myRecordListData);myRecyclerVIEwList.setAdapter(myCustomerAdapter);public class Speedylinearlayoutmanager extends linearlayoutmanager { private static final float MILliSECONDS_PER_INCH = 2f; //default is 25f (bigger = slower) public Speedylinearlayoutmanager(Context context) { super(context); } public Speedylinearlayoutmanager(Context context,int orIEntation,boolean reverseLayout) { super(context,orIEntation,reverseLayout); } public Speedylinearlayoutmanager(Context context,AttributeSet attrs,int defStyleAttr,int defStyleRes) { super(context,attrs,defStyleAttr,defStyleRes); } @OverrIDe public voID smoothScrollToposition(RecyclerVIEw recyclerVIEw,RecyclerVIEw.State state,int position) { final linearSmoothScroller linearSmoothScroller = new linearSmoothScroller(recyclerVIEw.getContext()) { @OverrIDe public PointF computeScrollVectorForposition(int targetposition) { return Speedylinearlayoutmanager.this.computeScrollVectorForposition(targetposition); } @OverrIDe protected float calculateSpeedPerPixel(displayMetrics displayMetrics) { return MILliSECONDS_PER_INCH / displayMetrics.densityDpi; } }; linearSmoothScroller.setTargetposition(position); startSmoothScroll(linearSmoothScroller); } }
总结 以上是内存溢出为你收集整理的android – textIsSelectable()在recyclerView中的TextViews的“浮动文本选择工具栏”中缺少项目全部内容,希望文章能够帮你解决android – textIsSelectable()在recyclerView中的TextViews的“浮动文本选择工具栏”中缺少项目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)