本文整理匯總了Java中android.support.v7.widget.RecyclerView.addItemDecoration方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.addItemDecoration方法的具體用法?Java RecyclerView.addItemDecoration怎麽用?Java RecyclerView.addItemDecoration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.addItemDecoration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
// Log.i("HabitUpDEBUG", "ViewHabitEventActivity onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_events);
events = new ArrayList<>();
eventListView = (RecyclerView) findViewById(R.id.event_list);
eventListView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setAutoMeasureEnabled(true);
eventListView.setLayoutManager(layoutManager);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
eventListView.addItemDecoration(itemDecoration);
}
示例2: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frm_clientes);
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.rvClientes);
mRecyclerView.setLayoutManager(new LinearLayoutManager(frmClientes.this));
mRecyclerView.addItemDecoration(new SpacesItemDecoration(Funcoes.SPACE_BETWEEN_ITEMS));
mAdapter = new adpClientes(frmClientes.this, mRecyclerView);
mRecyclerView.setAdapter(mAdapter);
ImageButton btnAdd = (ImageButton) findViewById(R.id.btnAdd);
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(frmClientes.this, frmManutencaoClientes.class);
intent.putExtra("Operacao", "I");
startActivity(intent);
}
});
}
示例3: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multidata);
adapter = new MultiTypeAdapter();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rlv_multidata);
initRegister();
setLayoutManager(recyclerView);
int space = getResources().getDimensionPixelSize(R.dimen.normal_space);
recyclerView.addItemDecoration(new ItemDecoration(space));
recyclerView.setAdapter(adapter);
initData();
// layoutManager.setSpanSizeLookup(spanSizeLookup);
adapter.setItems(items);
adapter.notifyDataSetChanged();
}
示例4: initView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void initView() {
folderWindow = new FolderWindow(this);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.app_name);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.mipmap.ic_back);
doneText = (TextView) findViewById(R.id.done_text);
doneText.setVisibility(selectMode == MODE_MULTIPLE ? View.VISIBLE : View.GONE);
previewText = (TextView) findViewById(R.id.preview_text);
previewText.setVisibility(enablePreview ? View.VISIBLE : View.GONE);
folderLayout = (LinearLayout) findViewById(R.id.folder_layout);
folderName = (TextView) findViewById(R.id.folder_name);
recyclerView = (RecyclerView) findViewById(R.id.folder_list);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, ScreenUtils.dip2px(this, 2), false));
recyclerView.setLayoutManager(new GridLayoutManager(this, spanCount));
imageAdapter = new ImageListAdapter(this, maxSelectNum, selectMode, showCamera, enablePreview);
recyclerView.setAdapter(imageAdapter);
}
示例5: initViews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initViews() {
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.member_list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter = new TeamMemberListAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.addItemDecoration(new DividerItemDecoration(
this, DividerItemDecoration.VERTICAL_LIST));
adapter.setListener(new TeamMemberListAdapter.ItemClickListener() {
@Override
public void onItemClick(TeamMember member) {
Intent intent = new Intent();
intent.putExtra(TeamExtras.RESULT_EXTRA_DATA, member);
setResult(Activity.RESULT_OK, intent);
finish();
}
});
ToolBarOptions options = new ToolBarOptions();
options.titleString = "選擇提醒的人";
setToolBar(R.id.toolbar, options);
}
示例6: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
setContentView(R.layout.activity_home);
if (getSupportActionBar() != null) getSupportActionBar().setTitle("Notifications");
progressFrame = findViewById(R.id.activity_notification_progress);
rv = (RecyclerView) findViewById(R.id.recycler_view);
LinearLayoutManager llm = new LinearLayoutManager(this);
rv.setLayoutManager(llm);
rv.addItemDecoration(new SimpleDividerItemDecoration(this));
rv.setHasFixedSize(true);
initializeData();
}
示例7: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bookmark_list, container, false);
// Set the adapter
RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
ViewStub zeroView = view.findViewById(R.id.zero_bookmarks);
UserDataDBHelper userDataDBHelper = UserDataDBHelper.getInstance(getContext(), bookId);
ArrayList<Bookmark> bookmarks = userDataDBHelper.getAllBookmarks(UserDataDBContract.BookmarkEntry.COLUMN_NAME_PAGE_ID);
if (bookmarks.size() != 0) {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
bookmarkRecyclerViewAdapter = new BookmarkRecyclerViewAdapter(bookmarks, mListener, getContext(), userDataDBHelper, getActivity().getPreferences(Context.MODE_PRIVATE));
bookmarkRecyclerViewAdapter.setHasStableIds(true);
recyclerView.setAdapter(bookmarkRecyclerViewAdapter);
} else {
recyclerView.setVisibility(View.GONE);
zeroView.setVisibility(View.VISIBLE);
}
return view;
}
示例8: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index_bar_test);
final List<ItemData> data = DataUtil.getItemDataList(555);
final RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new DividerDecoration());
IndexViewAdapter adapter = new IndexViewAdapter(data);
recyclerView.setAdapter(adapter);
final RecyclerIndex<ItemData> index = new RecyclerIndex<>(recyclerView);
index.attachIndex();
index.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getBaseContext(), ((Index) index.getData()).getText(), Toast.LENGTH_SHORT).show();
}
});
final RecyclerIndexBar<ItemData> indexBar = findViewById(R.id.index_bar);
indexBar.attach(recyclerView, index);
indexBar.setLayoutManager(new LinearLayoutManager(this));
IndexBarAdapter indexBarAdapter = new IndexBarAdapter(indexBar);
indexBar.setAdapter(indexBarAdapter);
indexBarAdapter.refresh(data);
}
示例9: getRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Get the recycler view for this fragment
*
* @param parent the view parent
* @return the {@link RecyclerView}
*/
public RecyclerView getRecyclerView(@NonNull final View parent) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getRecyclerView");
}
final RecyclerView mRecyclerView = (RecyclerView) parent.findViewById(R.id.layout_common_fragment_recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getParentActivity()));
mRecyclerView.addItemDecoration(new DividerItemDecoration(getParentActivity(), null));
return mRecyclerView;
}
示例10: initRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecyclerView(View v) {
recycleView = (RecyclerView) v.findViewById(R.id.recyclerView);
recycleView.setBackgroundColor(Color.parseColor("#eeeeee"));
recycleView.setItemAnimator(new DefaultItemAnimator());
recycleView.setLayoutManager(new LinearLayoutManager(getContext()));
//設置分割線
SoSpaceItemDecoration decoration = new SoSpaceItemDecoration(1);
recycleView.addItemDecoration(decoration);
//設置適配器
mNewsListAdapter = new NewsListAdapter(getContext(), null);
recycleView.setAdapter(mNewsListAdapter);
}
示例11: initViews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initViews() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mRecyclerView = (RecyclerView) findViewById(R.id.rvNewsType);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
mAllNewsTypeTittles = getResources().getStringArray(R.array.allNewsTypes);
mCheckedTypes = new ArrayList<>();
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("新聞分類展示");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
loadNewsChannels();
mRecyclerView.setAdapter(new NewsTypeAddRecyclerViewAdapter(mAllNewsTypeTittles, mCheckedTypes));
setOnNewsTypeChangeListener(mRecyclerView);
}
示例12: setRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void setRecyclerView(RecyclerView recyclerView) {
super.setRecyclerView(recyclerView);
recyclerView.addItemDecoration(new RecyclerViewItemDecoration.Builder(getActivity())
.color(ContextCompat.getColor(getActivity(), R.color.colorDivider))
.thickness(1)
.create());
}
示例13: getRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Get the recycler view for this fragment
*
* @param parent the view parent
* @return the {@link RecyclerView}
*/
public RecyclerView getRecyclerView(@NonNull final View parent) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getRecyclerView");
}
final RecyclerView mRecyclerView = (RecyclerView) parent.findViewById(R.id.layout_common_fragment_recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getParentActivity()));
mRecyclerView.addItemDecoration(new DividerItemDecoration(getParentActivity(), null));
return mRecyclerView;
}
示例14: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_list);
TitleBar _titleBar = (TitleBar) findViewById(R.id.titleBar);
_text_path = (EditText) findViewById(R.id.edittext_path);
RecyclerView _list = (RecyclerView) findViewById(R.id.recyclerview);
_buttonbar = (LinearLayout) findViewById(R.id.linearlayout_buttonbar);
View _button_delete = findViewById(R.id.textView_delete);
View _button_clean = findViewById(R.id.textView_clean);
View _button_hold = findViewById(R.id.textView_hold);
View _button_close = findViewById(R.id.imageview_close);
_checkbox_all = (CheckBox) findViewById(R.id.checkbox_all);
if (Global.get_rootFile() == null) {
FileManager.reset();
finish();
return;
}
_titleBar.setTitle(R.string.caption_text_mine);
_basic_path = Global.get_rootFile().get_path();
_text_path.setText(Global.get_rootFile().get_path().replace(_basic_path, getString(R.string.str_path_rootFile)));
_layoutManager = new LinearLayoutManager(this);
_layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
_list.setLayoutManager(_layoutManager);
_adapter = new FileListAdapter(this, this);
_adapter.set_data(Global.get_rootFile());
_list.setAdapter(_adapter);
_list.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
_broadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
_button_delete.setTag(new String[]{ACTION_DELETE});
_button_clean.setTag(new String[]{ACTION_CLEAN});
_button_hold.setTag(new String[]{ACTION_HOLD});
_checkbox_all.setTag(new String[]{ACTION_CHECK});
_button_close.setTag(new String[]{ACTION_CLOSE});
_button_delete.setOnClickListener(this);
_button_clean.setOnClickListener(this);
_button_hold.setOnClickListener(this);
_checkbox_all.setOnClickListener(this);
_button_close.setOnClickListener(this);
}
示例15: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
refreshLayout = (ISwipeRefreshLayout) findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(new ISwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// do refresh ...
handler.sendEmptyMessageDelayed(1, 3000);
}
});
refreshLayout.setRefreshHeaderView(new MedlinkerRefreshHeaderView(this));
handler.sendEmptyMessageDelayed(0, 2000);
refreshLayout.setEnabled(false);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
IDividerItemDecoration divierDecoration = new IDividerItemDecoration(this, IDividerItemDecoration.VERTICAL);
divierDecoration.setVerticalDividerHeight(3);
divierDecoration.setDividerColor(Color.BLUE);
divierDecoration.setDividerPadding(30);
recyclerView.addItemDecoration(divierDecoration);
recyclerView.setLayoutManager(getLayoutManager());
adapter = new MultiTypeLoadMoreAdapter();
adapter.register(TextItem.class, new TextItemViewBinder());
recyclerView.setAdapter(adapter);
adapter.setLoadMoreItemRetryListener(new OnLoadMoreRetryListener() {
@Override
public void onRetry() {
isLoading = true;
handler.sendEmptyMessageDelayed(2, 2000);
}
});
adapter.setLoadMoreSubject(new LoadMoreDelegate.LoadMoreSubject() {
@Override
public boolean isLoading() {
return isLoading;
}
@Override
public void onLoadMore() {
System.out.println(" onloacmore called ");
isLoading = true;
handler.sendEmptyMessageDelayed(2, 2000);
}
});
/* Mock the data */
// TextItem textItem = new TextItem("world");
adapter.setItems(createItems());
adapter.notifyDataSetChanged();
}