Recycler View, Adaper, ViewHolder

rather than creating list items as we scroll, keep them in a queue (recycling bin) → when scrolling, the list items are recycled and re-bind to new content. RecyclerView is better version of ListView.

Adaper: bind data from data source, and provide the RecyclerView with new views …

So far: single screen with a single activity.

start activity from another activity: use Intents.

Explicit intent: start a new activity

toy app: type some text, press button, and a new activity will appear with the typed words.

create activity in android studio: new → activity

call startActivity with an …

1 create project sunshine

Created 星期一 06 二月 2017

minSDK vs targetSDK

The minSDK is the lowest SDK level that your app can run on. You can choose what level of devices to support.

By comparison, the targetSDK is NOT a high pass filter -- it’s used …

2016年的最后几小时, 随便写写关于Scala和OCaml的一些入门体验好了.

今年对FP语言特别感兴趣, 上了两门Scala的公开课(here and here)和一门OCaml的公开课(here), 在博客中写了一系列的笔记, 课后作业也都认真做完了. 斗胆 …

this week: programming-in-the-large using the module system of OCaml.

1. STRUCTURING SOFTWARE WITH MODULES

in large project: mangage high number of definitions → abstractions built on top of other abstractions.

  • layers of abstractions: hide information
  • divide program into components
  • identifiers organised to avoid naming conflicts

module as namespace

dot-notation: access module …

1. IMPERATIVE FEATURES IN OCAML

functional language:

  • immutable data structure
  • identifiers instead of variables
  • pure functions

but imperative features are useful:

  • exceptions to alter control flow
  • ops to consume input and output
  • mutable data structures
  • for and while loop for iterations

2. GETTING AND HANDLING YOUR EXCEPTIONS

  • exceptions in ocaml …

1. FUNCTIONAL EXPRESSIONS

syntax for functional expr: function some_identifier -> some_expr
the type of the functional expr is t1 -> t2 where t1 is the type of some_identifier, t2 is type of some_expr

ex.

function x -> x + 1;;  
(function x -> 2*x) 5;; (*annonymous function*)   

the previous way of defining function:

let …

Last week, we only defined flat data structures which are nice to aggregate values but quite limited when you try to structure values.

This week: algebraic datatypes.

1. TAGGED VALUES

⇒ change the return type to a type query_result, which can be either of these:

  • an error
  • a new database (in …