本文整理匯總了Java中android.support.v7.widget.LinearLayoutManager.scrollToPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayoutManager.scrollToPosition方法的具體用法?Java LinearLayoutManager.scrollToPosition怎麽用?Java LinearLayoutManager.scrollToPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.scrollToPosition方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showRecyclerAdapter
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void showRecyclerAdapter() {
mAdapter = new NavAdapter(this,mArrayList, Typeface.createFromAsset(getAssets(),"fonts/Roboto-Light.ttf"));
RecyclerView rec = (RecyclerView)(findViewById(R.id.recyclerNav));
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
rec.setLayoutManager(linearLayoutManager);
rec.setAdapter(mAdapter);
mAdapter.onRecyclerClick(this);
if(mArrayList.size() == 3)
linearLayoutManager.scrollToPosition(mArrayList.size()+1);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rec.getContext(),
DividerItemDecoration.VERTICAL);
rec.addItemDecoration(dividerItemDecoration);
ItemTouchHelper helper = new ItemTouchHelper(callBack());
helper.attachToRecyclerView(rec);
}
示例2: setUpHistory
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void setUpHistory(RecyclerView historyView) {
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
historyView.setLayoutManager(layoutManager);
historyView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
final FloatingHistoryAdapter historyAdapter = new FloatingHistoryAdapter(mContext, mSolver, mHistory, mHistoryCallback);
mHistory.setObserver(new History.Observer() {
@Override
public void notifyDataSetChanged() {
historyAdapter.notifyDataSetChanged();
}
});
historyView.setAdapter(historyAdapter);
layoutManager.scrollToPosition(historyAdapter.getItemCount() - 1);
}
示例3: initializeRecyclerView
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void initializeRecyclerView(final View layout) {
// Get RecyclerView
mRecyclerView = UI.findViewById(layout, R.id.recycler_view);
// Choose the LayoutManager
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
layoutManager.scrollToPosition(0);
mRecyclerView.setLayoutManager(layoutManager);
}