Shortcuts Flashcards

1
Q

Run app in emulator

A

Shift F10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Save all

A

Cntl S

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Comment 1 line

A

Ctnl /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Comment multi lines

A

Ctnl Shift /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create function on custom method name()

A

Alt Shift Enter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Reformat all selected code

A

Cntl Alt L

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do the sizes mean sp vs dp

A

Sp = Scalable Pixels, text size is 36sp

Dp = Density Pixels, layout size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you import images?

A

Resource manager > [+] > import Drawables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you auto write the include libraries when you add code?

A

File > Settings > Editor > General > Auto import

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Include a val in text string?

A

Add $ before Val

E.g. “Your ${valName.funName} rest of text”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Add param to a function. Int?

A

fun name(val nums: Int) {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Find item by resource ID?

A

val textValue = findViewById(R.string.string_name)

val myButton: Button = findViewById(R.id.button)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How donyou set up a button click?

A

setOnClickListener

myButton.setOnClickListener { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Set text on a text view?

A

myTextView.text = “new text”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Structure of if?

A
val num = 4
if (num > 4) {
 X
} else if (num == 4) {
 Y 
} else {
 Catch all }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Structure of when?

A
when (myValue) {
 1 -> code
 2-> code 2
 else -> code n
}
17
Q

How does binding work?

A

Do it upfront, then don’t have to do lots of findById calls.

class MainActivity : AppCompatActivity(){

lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflator)
setContentView(binding.root)
}
}

//ref by binding
myButton.text = "Click me"
18
Q

How are colurs used?

A
Colours.xml = #here's
Theme.xml = colour names
19
Q

Val or var for a mutable list?

A

Val as the reference to the actual list doesn’t change, just the contents.

20
Q

When to use while vs for loops?

A

For loops are quicker and more concise, no need for i++

for (name in names)