本文整理匯總了Java中android.support.v7.widget.RecyclerView.ItemDecoration方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.ItemDecoration方法的具體用法?Java RecyclerView.ItemDecoration怎麽用?Java RecyclerView.ItemDecoration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.ItemDecoration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_completed_tasks);
Toolbar toolbarCompletedTasks = (Toolbar) findViewById(R.id.toolbar_task_completed);
setSupportActionBar(toolbarCompletedTasks);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (RecyclerView)findViewById(R.id.recyclerView_completed);
mTextEmptyList = (TextView) findViewById(R.id.text_noTask);
mLayoutManager = new LinearLayoutManager(getApplicationContext());
mDbHelper = new DBHelper(getApplicationContext());
mCompletedList = new ArrayList<>();
mAdapter = new CompletedTasksAdapter(mCompletedList,CompletedTasksActivity.this);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView.ItemDecoration itemDecoration = new
DividerItemDecoration(this,DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(itemDecoration);
setClickListeners();
//Load all saved Tasks
new LoadCompletedTasks().execute();
}
示例2: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_task_list, container, false);
mTextEmptyList = (TextView) view.findViewById(R.id.text_empty_list);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_main);
mFab = (FloatingActionButton) view.findViewById(R.id.fab_add);
mLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView.ItemDecoration itemDecoration = new
DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(itemDecoration);
setClickListeners();
setupBroadcastReceiver();
return view;
}
示例3: 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);
}
示例4: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grid_layout);
Intent intent = getIntent();
final int type = intent.getIntExtra(TYPE, 0);
final int left = intent.getIntExtra(LEFT, 0);
final int top = intent.getIntExtra(TOP, 0);
final int right = intent.getIntExtra(RIGHT, 0);
final int bottom = intent.getIntExtra(BOTTOM, 0);
@Orientation final int orientation = intent.getIntExtra(ORIENTATION, LinearLayout.VERTICAL);
recyclerview = (RecyclerView) findViewById(R.id.recyclerview);
List<String> strings = Arrays.asList(MainActivity.getList());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(strings.subList(1, strings.size()), orientation == LinearLayoutManager.HORIZONTAL);
RecyclerView.ItemDecoration itemDecoration;
if (type == SPACE) {
itemDecoration = new GridLayoutSpaceItemDecoration.Builder()
.build();
} else if (type == DIVIDER) {
itemDecoration = new GridLayoutDividerItemDecoration.Builder()
.setDividerColor(Color.RED)
.setLeftMargin(left)
.setTopMargin(top)
.setRightMargin(right)
.setBottomMargin(bottom)
.build();
} else {
itemDecoration = new GridLayoutDividerItemDecoration.Builder()
.setLeftMargin(left)
.setDividerDrawable(getResources().getDrawable(R.drawable.red2blue))
.setTopMargin(top)
.setRightMargin(right)
.setBottomMargin(bottom)
.build();
}
recyclerview.setLayoutManager(new GridLayoutManager(this, 3, orientation, false));
recyclerview.addItemDecoration(itemDecoration);
recyclerview.setAdapter(adapter);
}
示例5: addItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addItemDecoration(RecyclerView.ItemDecoration decor) {
recyclerView.addItemDecoration(decor);
}
示例6: removeItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void removeItemDecoration(RecyclerView.ItemDecoration decor) {
recyclerView.removeItemDecoration(decor);
}
示例7: showTrackedCoins
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void showTrackedCoins(PriceMultiFull priceMultiFull) {
PriceMultiFull price = priceMultiFull;
HashMap display = priceMultiFull.getDISPLAY();
ArrayList<DisplayPrice> displayPrices = new ArrayList<>();
ArrayList<RawPrice> rawPrices = new ArrayList<>();
RecyclerView.ItemDecoration dividerItemDecoration =
new RVDividerItemDecoration(ContextCompat.getDrawable(this,
R.drawable.bg_rv_separator));
if (display.size() > 0) {
displayPrices = priceMultiFull.getDisplayPrices();
rawPrices = priceMultiFull.getRawPrices();
myCoinsAdapter = new MyCoinsAdapter(this, displayPrices, rawPrices, this);
layoutManager = new LinearLayoutManager(this);
ScaleInAnimator animator = new ScaleInAnimator();
animator.setChangeDuration(2000);
rvMyCoins.setAdapter(myCoinsAdapter);
rvMyCoins.setLayoutManager(layoutManager);
rvMyCoins.setNestedScrollingEnabled(false);
rvMyCoins.setItemAnimator(animator);
if (!isRefreshUserCoins) {
// add item decoration only once
rvMyCoins.addItemDecoration(dividerItemDecoration);
} else {
isRefreshUserCoins = false;
}
if (isCoinAdded) {
Alerter.create(this)
.setTitle("Your coin(s) have been added")
.setBackgroundColorRes(R.color.colorPositiveNotification)
.setIcon(R.drawable.ic_thumbs_up_o)
.setDuration(2000)
.show();
isCoinAdded = false;
}
} else {
// TODO show meaningful error
}
}
示例8: removeItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void removeItemDecoration(RecyclerView.ItemDecoration itemDecoration) {
mRecycler.removeItemDecoration(itemDecoration);
}
示例9: addItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addItemDecoration(RecyclerView.ItemDecoration itemDecoration, int index) {
mRecycler.addItemDecoration(itemDecoration, index);
}
示例10: createItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected RecyclerView.ItemDecoration createItemDecoration() {
return null;
}
示例11: addItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addItemDecoration(RecyclerView.ItemDecoration itemDecoration) {
if (itemDecoration != null) {
display.addItemDecoration(itemDecoration);
}
}
示例12: addItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addItemDecoration(RecyclerView.ItemDecoration decor) {
mRecyclerView.addItemDecoration(decor);
}
示例13: getItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected RecyclerView.ItemDecoration getItemDecoration() {
return new DividerItemDecoration(getApplicationContext(), R.drawable.list_divider);
}
示例14: getItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Returns the item decoration for the recycler view.
*/
public RecyclerView.ItemDecoration getItemDecoration() {
// We don't draw any headers when we are uncomfortably dense
return mItemDecoration;
}
示例15: addItemDecoration
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addItemDecoration(RecyclerView.ItemDecoration itemDecoration) {
mRecyclerView.addItemDecoration(itemDecoration);
}