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