大约有 920 项符合查询结果(耗时:0.0165秒) [XML]
How to pass an object from one activity to another on Android
...on.fromJson(getIntent().getStringExtra("myjson"), YourObject.class);
For Kotlin it's quite the same
Pass the data
val gson = Gson()
val intent = Intent(this, YourActivity::class.java)
intent.putExtra("identifier", gson.toJson(your_object))
startActivity(intent)
Receive the data
val gson = Gso...
How to find/remove unused dependencies in Gradle
...
This plugin sadly doesn't work with the kotlin dsl. They have no plans to support it.
– snowe
Feb 1 '19 at 18:09
3
...
Saving and Reading Bitmaps/Images from Internal memory in Android
...
For Kotlin users, I created a ImageStorageManager class which will handle save, get and delete actions for images easily:
class ImageStorageManager {
companion object {
fun saveToInternalStorage(context: Context, bit...
How do I open the SearchView programmatically?
...s from other fragment.
if (myViewModel.filterTextSaved.isNotEmpty()) { // Kotlin, storing state in ViewModel
searchItem.expandActionView() // needs to come first, otherwise empty text
theTextArea.setText(courseViewModel.filterTextOnClick)
}
and for the menu I keep always|collapseActionVie...
Error 908: Permission Receive SMS - #5 by Taifun - MIT App Inventor Help - MIT App Inventor Community
...
This APK contains code Java or Kotlin, which can be obfuscated
Susan_Lane
...
How can I parse a local JSON file from assets folder into a ListView?
...
With Kotlin have this extension function to read the file return as string.
fun AssetManager.readAssetsFile(fileName : String): String = open(fileName).bufferedReader().use{it.readText()}
Parse the output string using any JSON p...
How do you compare two version Strings in Java?
...
converted on Kotlin stackoverflow.com/a/61795721/6352712
– Serg Burlaka
May 14 at 13:04
...
windowSoftInputMode=“adjustResize” not working with translucent action/navbar
... method and only devices >= 21 will execute the code inside the lambda. Kotlin example:
ViewCompat.setOnApplyWindowInsetsListener(container) { view, insets ->
insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom).apply {
ViewCompat.onApplyWindowInsets(view, this)
...
Clear the entire history stack and start a new activity on Android
...tFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Kotlin
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
Unfortunately for API lvl <= 10, I haven't yet found a clean solution to this.
The "DontHackAndroidLikeThis" solution is indeed pure ...
How to make an Android device vibrate?
... ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(150);
}
}
Kotlin:
// Vibrate for 150 milliseconds
private fun shakeItBaby(context: Context) {
if (Build.VERSION.SDK_INT >= 26) {
(context.getSystemService(VIBRATOR_SERVICE) as Vibrator).vibrate(VibrationEffect.createOne...
