Display new items at the top of a ListView

前端 未结 8 823
北恋
北恋 2021-01-02 06:28

I\'m using a list to populate a ListView (). The user is able to add items to the list. However, I need the items to be displayed at the top of the ListView. How do I insert

8条回答
  •  攒了一身酷
    2021-01-02 06:39

    mBlogList is a recycler view...

    mBlogList=(RecyclerView) findViewById(R.id.your xml file);
    mBlogList.setHasFixedSize(true);
    
    
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setReverseLayout(true);
    mLayoutManager.setStackFromEnd(true);
    mBlogList.setLayoutManager(mLayoutManager);//VERTICAL FORMAT
    

提交回复
热议问题