Show last item in ListiView when you click on edit text

前端 未结 4 522
臣服心动
臣服心动 2021-01-01 01:07

currently I\'m doing this to get the focus of the last item in a listview after clicking on an edit text:

    bodyText.setOnFocusChangeListener(new OnFocusCh         


        
4条回答
  •  不知归路
    2021-01-01 01:12

    For Someone who works with new RecyclerView widget that is recommended:

    just like accepted answer but replace:

    setSelection(getCount());
    

    with this:

     (LinearLayoutManager)getLayoutManager())
    .scrollToPositionWithOffset(getAdapter().getItemCount() - 1, 0);
    

    just LinearLayoutManagerand StaggeredGridLayoutManager have this method. so use this LayoutManagers.

提交回复
热议问题