March 2013
Beginner to intermediate
580 pages
16h 11m
English
In this chapter, you will learn more about layouts and widgets while adding a crime’s date and status to CriminalIntent.
Open Crime.java and add two new fields. The Date field represents the date a crime occurred. The boolean field represents whether the crime has been solved.
Listing 8.1 Adding more fields to Crime (Crime.java)
public class Crime {
private UUID mId;
private String mTitle;
private Date mDate;
private boolean mSolved;
public Crime() {
mId = UUID.randomUUID();
mDate = new Date();
}
...
}
Initializing the Date variable using the default Date constructor sets mDate to the current date. This will be the default date for a crime.
Next, generate getters and setters for ...
Read now
Unlock full access