這是我的onCreate處理該適配器,LinearLayoutManager等 我想每一個選項來嘗試它滾動到頂部,但不能。 我甚至嘗試創建我自己的自定義LinearLayoutManager。的Android recyclerview滾動到頂部
//Reson for static to call from a static method to scroll it up
private static RecyclerView taskRecyclerView;
private FirebaseAdapter firebaseAdapter;
private static LinearLayoutManager linearLayoutManager;
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_tasklist, container, false);
linearLayoutManager = new LinearLayoutManager(getActivity());
taskRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_mainTask);
databaseRef = FirebaseDatabase.getInstance().getReference().child(userAccount.getId());
firebaseAdapter = new FirebaseAdapter(TaskObject.class, R.layout.one_task, TaskViewHolder.class, databaseRef.child("Task"), getContext());
linearLayoutManager.setReverseLayout(true);
linearLayoutManager.setStackFromEnd(true);
linearLayoutManager.setSmoothScrollbarEnabled(true);
taskRecyclerView.setAdapter(firebaseAdapter);
taskRecyclerView.setLayoutManager(linearLayoutManager);
relativeLayoutAdd.setOnClickListener(this);
//Listen for any data change
databaseRef.child("Task").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//onDataChange called so remove progress bar
//make a call to dataSnapshot.hasChildren() and based
//on returned value show/hide empty view
//use helper method to add an Observer to RecyclerView
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
databaseRef.child("Task").keepSynced(true);
return view;
}
你爲什麼要改變你的LLM?每次添加到recyclerview的底部時,是否要滾動到底部?像短信應用程序? –
我想要最新的一個始終處於頂端。這就是爲什麼我將其扭轉。 – nnn
你可以用UI顯示一個例子嗎?如果您想將項目添加到回收站視圖的頂部,則不必反轉LLM,但必須反轉陣列。如果可以,請用Image解釋。我不確定你的問題是什麼。 –