Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
22 Cards in this Set
- Front
- Back
Button & Button click event |
- after the button is clicked - Android system receive the event - only the listener is interested in reacting to the event * OnClickListener |
|
a. Tell Android system that we are interested in listening to button clicks |
public class MainAcitivity extends Activity implements View.OnClickListener |
|
b. retrieve/linking the button from the XML layout into Java code (protected void onCreate(Bundle savedInstanceState)) |
myButton = (Button) findViewById(R.id.button); |
|
c. tell Java that we are listening to the button being clicked (protected void onCreate(Bundle savedInstanceState)) |
myButton.setOnClickListener(this); |
|
d. behavior: what should happen when the button is clicked |
@Override public void onClick(View v) { Toast.makeText(this, "button clicked", Toast.LENGTH_LONG).show() |
|
view |
an object that occupies a rectangular area on screen and is responsible for handling events eg: button |
|
view group |
occupies a rectangular area on screen, is invisible and holds other views in a certain structure (grid, horizontally, vertically, table etc) |
|
Linear Layout in XML |
all views and ViewGroups are placed in 1 ViewGroup which is the root |
|
root view |
width & height usuallt set to match_parent, to fill up all available space |
|
layout_weight attribute |
- affect the size of 1 view in relationship to other views - default 0 - layout_width is redundant - layout_width should be "0dp" |
|
layout_gravity attribute |
controls the placement of the view in the layout inside the parent * outside of view, ref to parent |
|
gravity attribute |
controls where the contents of the view should appear inside the view * inside of view, content |
|
calculator example |
vertical layout { //@+id/biglayout horizontal layout {} //@+id/horizTopLayout table layout {} //@+id/keysTableLayout } |
|
ListView concept |
1. define the data source 2. define the ListAdapter : class to manage the date 3. define the user interaction (ListView) : class to manage the apperance |
|
Adapter |
- responsible for managing the data - access the data display it in a view * takes data and convert it |
|
types of Adapter |
1. array adapter 2. cursor adapter 3. base adapter |
|
1. define the data source |
String [] courses = {"381"," 445"," 455"}; |
|
2. define the ListAdapter |
ArrayAdapter <String> adapter = new ArrayAdapter <String> (this, android.R.layout.simple_List_item_1, courses); this --> content android.R.layout.simple_List_item_1 --> TextView courses --> data source |
|
3. define the user interface |
a. MainActivity --> implements interface OnItemClickListener b. onCreate --> myList.setOnItemClickListener (this); c. implements the method of the OnItemClickListener interface --> @Override public void onItemClick (AdapterView<?> parent, View view, int position, long id) {} |
|
what is intent? |
asynchronous messaging mechanism that allow the Android components to request functionality from other components of the Android system (eg: Activity,Service, Broadcast receiver), and it can also be used to signal the Android system that a certain event has occured |
|
explicit intent |
define the component name which should be called by the Android system by using Java class as identifier Intent i = new Intent (this, ActivityTwo.class) |
|
implicit intent |
define the action which should be performed Intent i = (Intent.ACTION_VIEW); the Android system searches for all components which are registered for the specific action and the data type * if only 1 components is found, it start directly *many found: get a selection dialog and decide which component to use |