Search in sources :

Example 1 with RecyclerViewAdapter

use of com.daimajia.swipedemo.adapter.RecyclerViewAdapter in project AndroidSwipeLayout by daimajia.

the class RecyclerViewExample method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recyclerview);
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle("RecyclerView");
        }
    }
    // Layout Managers:
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    // Item Decorator:
    recyclerView.addItemDecoration(new DividerItemDecoration(getResources().getDrawable(R.drawable.divider)));
    recyclerView.setItemAnimator(new FadeInLeftAnimator());
    // Adapter:
    String[] adapterData = new String[] { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" };
    mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
    mAdapter = new RecyclerViewAdapter(this, mDataSet);
    ((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
    recyclerView.setAdapter(mAdapter);
    /* Listeners */
    recyclerView.setOnScrollListener(onScrollListener);
}
Also used : FadeInLeftAnimator(jp.wasabeef.recyclerview.animators.FadeInLeftAnimator) RecyclerViewAdapter(com.daimajia.swipedemo.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.daimajia.swipedemo.adapter.util.DividerItemDecoration) ActionBar(android.app.ActionBar)

Aggregations

ActionBar (android.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerViewAdapter (com.daimajia.swipedemo.adapter.RecyclerViewAdapter)1 DividerItemDecoration (com.daimajia.swipedemo.adapter.util.DividerItemDecoration)1 FadeInLeftAnimator (jp.wasabeef.recyclerview.animators.FadeInLeftAnimator)1