Search in sources :

Example 1 with SwipeRecyclerView

use of com.yanzhenjie.recyclerview.SwipeRecyclerView in project SwipeRecyclerView by yanzhenjie.

the class MenuActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_menu);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    SwipeRecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    recyclerView.setSwipeMenuCreator(mSwipeMenuCreator);
    mAdapter = new GroupAdapter();
    recyclerView.setAdapter(mAdapter);
    mAdapter.setListItems(createDataList());
}
Also used : DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 2 with SwipeRecyclerView

use of com.yanzhenjie.recyclerview.SwipeRecyclerView in project SwipeRecyclerView by yanzhenjie.

the class HeaderViewActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    SwipeRecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setOnItemClickListener(this);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    // HeaderView。
    View headerView = getLayoutInflater().inflate(R.layout.layout_header, recyclerView, false);
    headerView.findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(v.getContext(), "HeaderView", Toast.LENGTH_SHORT).show();
        }
    });
    recyclerView.addHeaderView(headerView);
    // FooterView。
    View footerView = getLayoutInflater().inflate(R.layout.layout_footer, recyclerView, false);
    footerView.findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(v.getContext(), "FooterView", Toast.LENGTH_SHORT).show();
        }
    });
    recyclerView.addFooterView(footerView);
    MainAdapter mainAdapter = new MainAdapter(this);
    recyclerView.setAdapter(mainAdapter);
    mainAdapter.notifyDataSetChanged(createDataList());
}
Also used : MainAdapter(com.yanzhenjie.recyclerview.sample.adapter.MainAdapter) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)2 Toolbar (androidx.appcompat.widget.Toolbar)2 SwipeRecyclerView (com.yanzhenjie.recyclerview.SwipeRecyclerView)2 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)2 View (android.view.View)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 MainAdapter (com.yanzhenjie.recyclerview.sample.adapter.MainAdapter)1