RecycleView
RecyclerView.Adapter<T extends BaseAdapter>
RecyclerView.ViewHolder<T extends BaseViewHolder>
LinearLayoutManager
RecycleView
RecyclerView.Adapter
RecyclerView.ViewHolder<T extends BaseViewHolder>
LinearLayoutManager
RecycleView
RecyclerView.Adapter
RecyclerView.ViewHolder
LinearLayoutManager
RecycleView
RecyclerView.Adapter<VH extends ViewHolder>
RecyclerView.ViewHolder
LinearLayoutManager
Intent(this, NextActivity::class.java).also { intent ->
startActivity(intent)
}
Intent(this, NextActivity::class.java).apply {
put(EXTRA_NEXT, "some data")
}.also { intent ->
activityStart(intent)
}
Intent(this, NextActivity::class.java).apply {
putExtra(EXTRA_NEXT, "some data")
}.also { intent ->
startActivity(intent)
}
Intent(this, NextActivity::class.java).apply {
put(EXTRA_NEXT, "some data")
}.also { intent ->
activityStart(intent)
}
в build.gradle: include ':app',':about' ':settings'в settings.gradle: include ':app',':about' ':settings'в settings.gradle: include ':about',':settings'в gradle.properties: include ':app',':about' ':settings' defaultConfig {
...
minApiVersion 21
targetApiVersion 28
}
defaultConfig {
...
targetSdkVersion 21
testSdkVersion 28
}
defaultConfig {
...
minSdkVersion 21
testApiVersion 28
}
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
}
private lateinit var textView: TextView
override fun onCreateView(...): View? {
val root = inflator.inflator(R>layout.fragment_home, container, false)
textView = ??
return root
}
Примітка: AndroidJUnitRunner дозволяє нам запускати тести в стилі JUnit3/4 на Android-пристроях
Пояснення: У методі "getDefaultSharedPrefarances(this).getString()" другий параметр передається так, щоб він міг бути повернений, якщо ключ не існує. Тому нам потрібно передати порожній рядок для повернення у випадку, якщо ключ не існує.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/white" />
<solid android:color="@android:color/black" />
</shape>
<oval xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="@android:color/black"/>
<solid android:color="@android:color/white"/>
</oval>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/black" />
<solid android:color="@android:color/white" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/white" />
<solid android:color="@android:color/white" />
</shape>
<merge/><include/><layout/><add/>android.permission.ACCESS_NETWORK_STATE
LinearLayout? <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>




val dialerIntent = Intent()
val et = findViewById(R.id.some_edit_text)
dialerIntent.action = Intent.ACTION_DIAL
dialerIntent.data = Uri.parse("tel:" + et.getText()?.toString())
startActivity(dialerIntent)
startActivityWithResult() слід використовувати замість startActivity() при використанні Intent.ACTION_DIALIntent.ACTION_DIAL, опція Intent Intent.FLAG_ACTIVITY_NEW_TASK має бути додана при використанні цього dialerIntentdialerIntent викличе ActivityNotFoundException на пристроях, які не підтримують Intent.ACTION_DIALandroid.permission.CALL_PHONE повинен бути запитаний спочатку, перш ніж можна буде використовувати Intent.ACTION_DIAL/assets?resource ID, наприклад R.assets.filenameResources.openRawResource()intent, замість прямого запиту дозволу камери?intent камери, поважатиме ваші рішення щодо дизайнуintent камери, надасть UIActivityCompat.shouldShowRequestPermissionRationale()?release збірках. Як ви можете створити нове поле у згенерованому класі BuildConfig для зберігання цього значення?buildTypes {
debug {
buildConfig 'boolean', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfig 'boolean', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfig 'String', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfig 'String', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
}
release {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
}
}
ProGuard до об’єктів передачі мережевих даних (DTO)@SerizlizedName, застосований до його властивостей-членів
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:padding="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
Activity через intent? <activity android:name=".ExampleActivity" />
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
</intent-filter>
</activity>
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
Пояснення: Intent-фільтри використовуються для забезпечення доступності активностей іншим додаткам за допомогою intent. Тому ми повинні вибрати варіант, у якому немає intent-фільтра, щоб переконатися, що він недоступний через intent
ActivityManager.isLowRamDevice(), щоб дізнатися, чи визначає себе пристрій як “низька оперативна пам’ять”Activity.islowRam(), щоб дізнатися, чи визначає себе пристрій як “низька оперативна пам’ять”ConnectivityManager.hasLowMemory(), щоб дізнатися, чи визначає себе пристрій як “низька оперативна пам’ять”<include/> для їх включення в інші XML-файли макетів
<shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"oval">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"45"/>
</shape>
<rectangle xmlns:android-"http://schemas.android.com/apk/res/android">
<gradient
android:startColor-"@android:color/white"
android:endColor-"android:color/black"
android:angle-"135"/>
</rectangle>
<shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"rectangle">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"135"/>
</shape>
<shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"rectangle">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"98"/>
</shape>

android {
...
defaultConfig{...}
buildTypes{
debug{...}
releasae{...}
}
flavorDimensions "environment"
productFlavors {
producation {...}
staging {...}
}
}
Conversion to Dalvik format filed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
<?xml version=1.0 encoding="utf-8"?>
<resources>
<dimen name="spacing_medium">8dp</dimen>
<dimen name="spacing_large">12dp</dimen>
</resources>
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
androi:layout_botttom="@dimen/spacing_medium"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:layout_marginBottom="@resources/spacing_medium"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:layout_marginBottom="@dimen/spacing_medium"
android:src=@drawable/map_pin />
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_post_create)
if (savedInstanceState != null) return
val fragment = CreatePostFragment()
supportFragmentManager
.beginTransaction()
.add(R.id. fragment_container, fragment)
.commit()
}
Intent(this, AboutActivity::class).also { intent -> startService(intent)}Intent(this, AboutActivity::class.java).also { intent -> startActivity(intent)}Intent(this, AboutActivity::class).also { intent -> activity(intent)}Intent(this, AboutActivity::class).also { intent -> startActivity(intent)}Пояснення: Intent(Context packageContext, Class<?> cls) Примітка: Class, а не KClass
Пояснення: Коли ви збираєте свій проект, використовуючи плагін Android Gradle 3.4.0 або вище, плагін більше не використовує ProGuard для виконання оптимізації коду під час компіляції. Натомість плагін працює з компілятором R8 для обробки
A

B

C

D

BuildConfigBuildInfoConfigParamsConfigInfo <androidx.constraintlayout.widget.ConstrantLayout
...>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstrantLayout>
Кнопка не має розміруКнопка не обмежена до кінця батьківського контейнераКнопки не можуть розширюватися за межі їхнього розміру за замовчуваннямВисота кнопки також повинна бути встановлена на 0dpкерування системними службамиобробка подій введення користувачазавантаження даних з Інтернету або локального джерела данихвиконання перетворень bitmapStringTextString-arrayPluralsonPause()onResume()onOpen()onStart() fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.CAMERA) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
showCameraPreview()
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}
<string name="upload_photo_notification">%1$d of %2$d photos uploaded</string>
val string: String = getString(
R.string.upload_photo_notification,
"2",
"5"
)
val string: String = getString(
R.id.upload_photo_notification,
2,
5
)
val string: String = getString(
R.string.upload_photo_notification,
2,
5
)
val string: String = getString(
R.id.upload_photo_notification,
"2",
"5"
)
"You have 1 day remaining"
"You have 2 days remaining"
<string name="trial_days_left_one"> You have %1$d day remaining</string>
<string name="trial_days_left_other">You have %1$d days remaining</string>
<plurals name="trial days left">
<plural quantity="one">You have %1$d day remaining</plural>
<plural quantity="other">You have %1$d days remaining</plural>
</plurals>
<plurals name="trial_days_left">
<item quantity="one">You have %1$d day remaining</item>
<item quantity="other">You have %1$d days remaining</item>
</plurals>
<string name="trial_days_left">
<plural quantity="one">You have %1$d day remaining</plural>
<plural quantity="other">You have &1$d days remaining</plural>
</string>
коли додаток видаляєтьсяколи додаток переходить у фоновий режимколи пристрій знаходиться в режимі оптимізації батареїколи мережеві запити виконуються в головному потоці
recyclerView.setLayoutManager(GridLayoutManager(this, 3))
val coulumnCount = resources.getInteger(R.integer.column_count)
recyclerView.setLayoutManager(GridLayoutManager(this, columnCount))
recyclerView.setLayoutManager(LinearLayoutManager(this))
val coulumnCount = resources.getInteger(R.integer.column_count)
recyclerView.setLayoutManager(LinearLayoutManager(this, columnCount))
intent, замість прямого запиту дозволу камери?intent камери, поважатиме ваші рішення щодо дизайнуintent камери, надасть UI