Android Development by fredyonge yo Flashcards
dp
Measurement for pixels
alpha
Level of transparency
String
Class (not primitive) made of chars
sp
text pixel measurement
public
java code for accessible across entire application
static
Method relates to whole class and not just instances
extends
java code for passing attributes
protected
java code for privately accessible to specific package
println
Java code stands for Print Line
“AS: create public View class called view that returns nothing > call it with clickFunction > Log ““info”” ““Button pressed”””
“public void clickFunction(View view) { Log.f(““Info””, ““Button Press””); }”
AS: finde das Suchfehld email
EditText email = (EditText) findViewById(R.id.email);
AS: get email ID text > parse to string > log email text
“Log.i(““Info””, email.getText().toString());”
Where do images get stored in Android Studio?
The drawable folder
AS: find image1 ID defniiere es als image
ImageView image = (ImageView) findViewById(R.id.image1);
AS: set image resource of image as image2
image.setImageResource(R.drawable.image2);
AS: get text > parse to string > parse to double
Double doubleName= Double.parseDouble(stringName.getText().toString());
“Java: create class called ““HelloWorld”” > print ““Hello World!”””
“public class HelloWorld { public static void main(String[] args) { System.out.println(““Hello World””); }}”
What are classes in Java?
Type of object definition
What are methods in Java?
A chunk of code that does something
What is the main method in Java?
A method that runs when Java is executed
“Java: Log ““Hello World”””
“System.out.println(““Hello World””);”
Java: 8 types of primitives > bit size > purpose
1- boolean(true or false)2- char(16-bit, unicode character)3- byte(8-bit, save mem in large array)4- short(16-bit, save mem large array)5- int(32-bit, number)6- float(32-bit, use for short decimals)7- double(64-bit, decimal number)8- long(64-bit, for large range values)
What does Java do when you put a primitive in a string?
Converts it to a string
Java: create Arrays of Integers
int[] numbers = {1, 2, 3, 4,};
Java: get array length
numbers.length;//No parenthesis
Java Standard: import all util framework
import java.util.*;
Java: create List named listName > add new array constructor to list > add numbers to list > remove number to list > log an index > log entire array as string
ArrayList listName = new ArrayList(); listName.add(1);listName.add(2);listName.add(3);System.out.println(listName.get(2));listName.remove(2);System.out.println(listName.toString());
Map
Erstellt paare von Aufgaben
Java new map named favorits add color:blue , add afavNum: 7 > log Color > remove Num > log map size
“Map favorites = new HashMap();favorites.put(““color””, ““blue””);favorites.put(““num””, 7);System.out.println(favorites.get(““color””));favorites.remove(““num””);System.out.println(favorites.size());”
Java: tells us number of items in hash
map.size();
AS: convert string to integer
Integer.parseInt();
AS: solution to Error:Execution failed for task ‘:app:buildInfoDebugLoader’ bug
Go to Run > Click clean and rerun
Where do you do version control with git and github in AS?
Under the VCS tab
Java: create a for loop > count by 2s > start at 0 > end at 10
for (x = 0; x <= 10; x += 2) {}
Java: create a while loop > count by 1s > start at 0 > end at 10
int x = 0;while (x <= 10) { x++ }
array namens family durchgehen, jeden einzelnen Namen ausgeben
for (String name : family) { System.out.println(name);}
Java: create a list called family > make list contain strings > add 2 family members
“ArrayList family = new ArrayList();family.add(““Tony””);family.add(““CJ””);”
How can you align elements in AS? (4)
1) center of screen2) relative to another element3) corners 4) margin away from the above
What do you use to sub group elements linearly? (2)
horizontal or vertical linear layouts
AS: animate ID image > change transparency to 50% > set change for 1 second duration
image.animate().alpha(0.5f).setDuration(1000);
animate()
AS: Method changes the style properties of an element
translationXBy() / YBy()
AS: Method paired with animate() moves element vertically or horizontally
Get Arraylist Value
list.get(2) ; 2 = Number in array, list = arraylist name
AS: animate ID image > move image down vertically by 2000 pixels > do so over 2 seconds
image.animate().translationYBy(2000f).setDuration(2000);
AS: set ID image to 2000 pixels left on app startup
In onCreate methodimage.setTranslationX(-2000f);
rotation()
AS: Method rotates the element clock-wise
AS: rotate element image once over 2 seconds
image.animate().rotation(360f).setDuration(2000);