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)
}
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
}
Avviso: AndroidJUnitRunner ci consente di eseguire test in stile JUnit3 / 4 su dispositivi Android
Spiegazione: Nel metodo “getDefaultSharedPrefarances(this).getString()” viene passato il secondo parametro in modo che possa essere restituito, nel caso in cui la chiave non esista. Quindi dobbiamo passare una stringa vuota da restituire nel caso in cui la chiave non esista.
<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()
dovrebbe essere usato al posto di startActivity()
quando si utilizza Intent.ACTION_DIAL
.Intent.ACTION_DIAL
Le Intent
opzione Intent.FLAG_ACTIVITY_NEW_TASK
deve essere aggiunto quando si utilizza questo dialerIntent
.dialerIntent
causerà la visualizzazione di un’eccezione ActivityNotFoundException su dispositivi che non supportano Intent.ACTION_DIAL
.android.permission.CALL_PHONE
deve essere richiesto prima Intent.ACTION_DIAL
può essere utilizzato./assets
directory?resource ID
come R.assets.filename
Resources.openRawResource()
intent
, invece di richiedere direttamente l’autorizzazione della fotocamera?intent
rispetterà le tue scelte progettuali.intent
fornirà l’interfaccia utente.ActivityCompat.shouldShowRequestPermissionRationale()
funzione?release
costruisce. Come è possibile creare un nuovo campo nel generato BuildConfig
per memorizzare quel valore? 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
-keepclassmembers sono stati aggiunti agli oggetti di trasferimento dati di rete (DTO) in questione@SerizlizedName
applicato alle relative proprietà membro <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>
_not_
disponibile per impostazione predefinita quando Android Studio crea un nuovo progetto?Activity
tramite un 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>
Spiegazione: I filtri intento vengono usati per rendere le attività accessibili ad altre app usando gli intenti. Quindi dobbiamo scegliere l’opzione che non ha alcun filtro intento per assicurarci che non sia accessibile dall’intento
ActivityManager.isLowRamDevice()
per scoprire se un dispositivo si definisce come “RAM insufficiente”.Activity.islowRam()
per scoprire se un dispositivo si definisce come “RAM insufficiente”.ConnectivityManager.hasLowMemory()
per scoprire se un dispositivo si definisce come “RAM insufficiente”._not_
un buon modo per riutilizzare il codice Android?<include/>
per includerli in altri file XML di layout. <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(intento) }
Intent(this, AboutActivity::class.java).also { intent -> startActivity(intento) }
Intent(this, AboutActivity::class).also { intent -> attività(intento) }
Intent(this, AboutActivity::class).also { intent -> startActivity(intento) } Spiegazione: Intent(Context packageContext, Class<?> cls) Avviso: Classe non KClass
A
B
C
D
BuildConfig
BuildInfo
ConfigParams
ConfigInfo
<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 size
The button is not constrained to the end of the parent container
Buttons cannot expand beyond their default size
The button should have its height set to 0dp as well
managing system services
processing user input events
loading data from the internet or a local data source
perfoming bitmap transformatinos
String
Text
String-array
Plurals