Lesson 2 Flashcards
Connect to the Internet
log messages
messages to communicate information about application
log levels;
WTF (rarely/never used), error, warn, info, () debug, verbose “WEW DIV”
log syntax
log.x(String TAG, String message); typically use class name as TAG
typical ScrollView height, width
android: layout_height = “wrap_content”
android: layout_width=”match_parent”
Res folder types
holds resources; Strings, images, layouts.
Layouts: XML layouts
Animator: XML for property animations
Values: XML files that contain simple values, such as strings or integers
Anim: XML for tween animations
MIpmap: drawable launcher icon files
Drawable: visual files
Raw: arbitrary raw files
MEnu: XML for application menus
Xml: arbitrary XML
Color: XML for colors
“LAVA MiD R MeX (of) Color”
get layout in res how?
by calling R.layouts.; uses folder res/layouts/ hierarchy
get string in res how?
in res/values/strings.xml, call getString
set up layouts how/where?
in Android xml
xml menu orderInCategory
the order an item appears in a menu
action bar
above activity window, contains overflow menu, menu items are actions. can show buttons if room (showAsAction=”ifRoom”)
toolbar widget
generalized action bar; animated in and out
instantiate menu how?
in Java activity, override onCreateOptionsMenu
how to add new resource type
right click “res” folder, add new resource directory, pick appropriate resource type
code for inflating menu
@Override
public boolean onCreateOptionsMenu (Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
“OnCOM”
Uri.Builder
build uri from base, then parameters (such as search, and sort)
url and uri
url is subset of uri
Uri.Builder syntax
Uri builtUri = Uri.parse(GITHUB_BASE_URL).buildUpon().appendQueryParameter(PARAM_QUERY, githubSearchQuery).appendQueryParameter(t).build(); // building blocks of URI building: // GITHUB_BASE_URL = http://.... // PARAM_QUERY = "q" // PARAM_SORT = "sort" URL url = null; try { url = new URL(builtUri.toString()); } catch (MalformedURLException e){ e.printStackTrace(); }
do things when menu button pressed syntax
In activity,
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemThatWasClickedId = item.getItemId();
if (itemThatWasClickedId == R.id.action_search)
where to add permissions?
declare permissions in manifest
main thread term in android
“Single User Interfacing Thread”
network on which thread?
secondary execution thread,
AsyncTask runs, publishes to where?
Run task on background thread
Publish results on UI (main) thread