Android ListViews

 


Ivan Kocijan  -  ikocijan0@gmail.com
Milan  Jovanović  - milan.jovanovic24@gmail.com

Content

  • ScrollView
  • ListView
  • RecyclerView
  • CardView

Scroll View

  • Container for a view hierarchy that can be scrolled by the user
  • View hierarchy can be bigger then physical display
  • It has only one child view
  • Never use scroll view with a list view

Practice

ListView

2 ways of doing list view

  • Old one - easier to understand (in my opinion) - Using list adapter
  • New one - harder to understand (in my opinion) - Using RecyclerView

Which one are we going to use?





RecyclerView




But why???!!!??!

Because new is always better



"You know who's a million times hotter than the hottest girl I've ever slept with? Her okay-looking friend I haven't seen naked. Why? Because new is always better. "*







* Barney Stinson,  Season 6, Episode 5

What do we need?

  1. RecycleView
  2. List which contains our objects
  3. Adapter
  4. Add RecyclerView as a dependency


Using RecyclerView

  • Add RecyclerView to xml
  • Create and add Adapter to RecyclerView
  • Create and add LayoutManager to RecyclerView
  • Create and set ItemAnimator to RecyclerView
  • Create and add a list of objects to Adapter

Practice

CardView

  • CardView lets you show information inside cards
  • Used across Android platform
  • Google now
  • You can add shadows, elevation, corner radius etc.

CardView example





Practice

Homework

  • Add ListView to Weather application
  • Use Mock data

Materials from this workshop

Read more


Android lists - Workshop 2

By Ivan Kocijan Koc

Android lists - Workshop 2

Scroll view, list view, card view, adapters

  • 2,004