本文整理汇总了Java中android.support.v7.widget.DividerItemDecoration类的典型用法代码示例。如果您正苦于以下问题:Java DividerItemDecoration类的具体用法?Java DividerItemDecoration怎么用?Java DividerItemDecoration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DividerItemDecoration类属于android.support.v7.widget包,在下文中一共展示了DividerItemDecoration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_select_language, container, false);
ButterKnife.bind(this, v);
mRecycler.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecycler.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
visibleProgress(mProgress, true);
workAPI.getAllLanguage(new StringListCallback() {
@Override
public void onSuccess(@NonNull List<String> stringsList) {
languages.clear();
languages.addAll(stringsList);
actionSelectLanguage();
}
@Override
public void onError(@NonNull Throwable t) {
}
});
return v;
}
示例2: initView
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
public void initView(){
//initdata();
poemData = new ArrayList<SongCi>();
poemRecyclerView = (RecyclerView) cxt.findViewById(R.id.recycler_view);
poemAdapter = new PoemAdapter(cxt, poemData,poemRecyclerView);
poemRecyclerView.setAdapter(poemAdapter);//设置适配器
poemRecyclerView.setVerticalScrollBarEnabled(true);
//设置布局管理器 , 将布局设置成纵向
LinearLayoutManager
linerLayoutManager = new LinearLayoutManager(cxt, LinearLayoutManager.VERTICAL, false);
poemRecyclerView.setLayoutManager(linerLayoutManager);
//设置分隔线
poemRecyclerView.addItemDecoration(new DividerItemDecoration(cxt , DividerItemDecoration.VERTICAL));
//设置增加或删除条目动画
poemRecyclerView.setItemAnimator(new DefaultItemAnimator());
}
示例3: setUpAdapter
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override protected void setUpAdapter() {
if (null != getSupportActionBar()) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
SampleAdapter sampleAdapter =
new SampleAdapter(new BaseViewHolder.OnItemClickListener<String>() {
@Override public void onItemClick(View view, String item) {
gotoNextActivity(dataList.indexOf(item));
}
});
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(sampleAdapter);
sampleAdapter.setDataList(populateData());
}
示例4: onCreate
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview_test);
ButterKnife.bind(this);
LinearLayoutManager layoutManager = new LinearLayoutManager
(this,LinearLayoutManager.VERTICAL,false);
// GridLayoutManager gridLayoutManager = new GridLayoutManager(this,2);
// StaggeredGridLayoutManager staggeredLayoutManager = new StaggeredGridLayoutManager
// (2,StaggeredGridLayoutManager.VERTICAL);
recyclerview.setLayoutManager(layoutManager);
recyclerview.addItemDecoration
(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
// requestData();
getRemoteData();
}
示例5: setupRecyclerView
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
private void setupRecyclerView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(this, layoutManager
.getOrientation()));
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent intent = new Intent(MainActivity.this, TestViewActivity.class);
intent.putExtra(TestViewActivity.ARG_TEST_ID, socTests.get(position).getId());
startActivity(intent);
}
}));
socTests = daoSession.getSocTestDao().loadAll();
adapter = new TestRecyclerViewAdapter(socTests);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
示例6: initData
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
public void initData(Bundle savedInstanceState) {
mViewDataBinding.rvTeam.addItemDecoration(new DividerItemDecoration(getThis(), DividerItemDecoration.VERTICAL));
mViewDataBinding.rvTeam.setAdapter(mAdapter);
if (getArguments() != null) {
int seasion = getArguments().getInt("Seasion ID");
mSeasionName = getArguments().getString("Seasion Name");
mViewModel.getResults(seasion).observe(this, new Observer<Resource<List<TeamModel>>>() {
@Override
public void onChanged(@Nullable Resource<List<TeamModel>> listResource) {
mViewDataBinding.setResource(listResource);
mViewDataBinding.executePendingBindings();
if (listResource != null && listResource.data != null) {
mAdapter.updateData(listResource.data);
}
}
});
}
}
示例7: showData
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
/**
* 获取数据
*/
private void showData() {
List<ShoppingCart> carts = mCartShopProvider.getAll();
if (carts == null) {
initEmptyView(); //如果数据为空,显示空的试图
return;
}
/**
* 购物车数据不为空
*/
mAdapter = new ShopCartAdapter(getContext(), carts, mCheckBox, mTextTotal);
mRecyclerView.setAdapter(mAdapter);
//recyclerView本身存在一个bug,在删 添加数据同时进行时,会报错:
// java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder
// adapter positionViewHolder{42319ed8 position=1 id=-1, oldPos=0, pLpos:0 scrap
// tmpDetached no parent}
//需要 重写LinearLayoutManager
mRecyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL, false));
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
DividerItemDecoration.VERTICAL));
}
示例8: showData
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
/**
* 展示数据
*/
private void showData() {
if (datas != null && datas.size() > 0) {
mTxtSummary.setText("共有" + datas.size() + "件商品");
} else {
mLlSummary.setVisibility(View.GONE);
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
ToastUtils.showShortSafe("暂无商品信息");
return;
}
mAdatper = new HotGoodsAdapter(datas, this);
mRecyclerview.setAdapter(mAdatper);
if (actionType == ACTION_LIST) {
mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
} else {
mRecyclerview.setLayoutManager(new GridLayoutManager(this, 2));
}
mRecyclerview.setItemAnimator(new DefaultItemAnimator());
mRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration
.HORIZONTAL));
}
示例9: onCreateView
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_artists, container, false);
ButterKnife.bind(this, rootView);
adapter = new ListAdapter(getContext(), uiModel);
adapter.setOnItemClickListener(createOnArtistClickListener());
artistsView.setHasFixedSize(true);
artistsView.setAdapter(adapter);
artistsView.setLayoutManager(new LinearLayoutManager(getContext()));
artistsView.addItemDecoration(new DividerItemDecoration(getContext(),
LinearLayoutManager.VERTICAL));
listHelper = new ListViewHelper(artistsView, emptyListView, loadingProgressView);
FloatingActionButton addArtistButton = (FloatingActionButton) getActivity().findViewById(
R.id.fab_add_artist);
addArtistButton.setOnClickListener(v -> {
presenter.sendUiEvent(OpenNewArtistEvent.INSTANCE);
});
return rootView;
}
示例10: onViewCreated
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mRecyclerView = view.findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mAdapter = new DiagnosticAdapter(getContext(), new ArrayList<Diagnostic>());
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(),
DividerItemDecoration.VERTICAL));
mAdapter.setListener(new DiagnosticAdapter.OnItemClickListener() {
@Override
public void onClick(Diagnostic diagnostic) {
if (presenter != null) presenter.click(diagnostic);
}
});
}
示例11: initialize
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
public void initialize(Bundle savedInstanceState) {
super.initialize(savedInstanceState);
presenter.runProvider(this);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(this.getContext(), LinearLayoutManager.VERTICAL));
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
presenter.runProvider(CourseAllFragment.this, true);
}
});
}
示例12: onViewCreated
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mRecyclerView = (RecyclerView) view;
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(),DividerItemDecoration.VERTICAL));
mRecyclerView.setAdapter(mAdapter = new BaseRecyclerAdapter<Void>(initData(), simple_list_item_2) {
@Override
protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
holder.text(android.R.id.text1, String.format(Locale.CHINA, "第%02d条数据", position));
holder.text(android.R.id.text2, String.format(Locale.CHINA, "这是测试的第%02d条数据", position));
holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
}
});
}
示例13: setupRecyclerView
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
public static void setupRecyclerView(EmptySupportedRecyclerView recyclerView,
Context context, View emptyView) {
// set view to display when there is any content
recyclerView.setEmptyView(emptyView);
recyclerView.setHasFixedSize(true);
// set layout manager as linear
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(linearLayoutManager);
// add divider between items
DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration(context, linearLayoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
}
示例14: init
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(title);
}
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(activity, layoutManager.getOrientation()));
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(genreAdapter);
}
示例15: initLayout
import android.support.v7.widget.DividerItemDecoration; //导入依赖的package包/类
private void initLayout() {
mProgressBar.setVisibility(View.VISIBLE);
mSwipeRefreshLayout.setVisibility(View.GONE);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent,
android.R.color.holo_red_light,
android.R.color.holo_orange_light,
android.R.color.holo_green_light);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
isRefresh = true;
mPresenter.getMovie(10, 10);
}
});
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addItemDecoration(new DividerItemDecoration(this,
DividerItemDecoration.VERTICAL));
}