本文整理汇总了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);
}