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)
}
in build.gradle:include ':app',':about' ':settings'in settings.gradle:include ':app',':about' ':settings'in settings.gradle:include ':about',':settings'in 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
}
Notice: AndroidJUnitRunner lets us run JUnit3/4-style tests on Android Devices
Explanation: In Method "getDefaultSharedPrefarances(this).getString()" The Second parameter is passed so that it can be returned, in case the key doesn't exist. So we need to pass an empty string to be returned in case the key doesn't exist.

<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
android:id 属性android:background 属性android:foreground 属性public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED){
// A
} else {
// B
}
}
findViewById()。应该采取以下哪种步骤?android:dataBindingEnabled="true" 属性<layout> 标签添加到布局 XML 文件的顶部listView.isClickable = falselistView.setClickable(false)listView.clickable(false)android:srcandroid:imgandroid:imageandroid:sourceproductFlavors 块中添加 API 21 支持<uses-sdk> 中添加 API 21 支持build.gradle 文件的 defaultConfig 块中添加 API 21 支持android logcatcd logcatadb logcatgradle logcatby lazy 属性应该用于什么?public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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)}Explanation: Intent(Context packageContext, Class<?> cls) Notice: Class not KClass
Explanation: When you build your project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler.
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>
The button does not have a sizeThe button is not constrained to the end of the parent containerButtons cannot expand beyond their default sizeThe button should have its height set to 0dp as wellmanaging system servicesprocessing user input eventsloading data from the internet or a local data sourceperforming bitmap transformationsStringTextString-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>
when the app is uninstalledwhen the app is backgroundedwhen the device is in battery optimization modewhen network requests are made on the main thread
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 而不是直接请求 camera permission 的优势?intent 的应用会遵循您的设计选择intent 的应用会提供 UI