ViewBindingを使ってAndroid開発をしているとき、
大量にViewを作るとBindingでエラーなることがあった。
メールアドレスのみで認証する、パスワード設定が不要な認証方法です。
// 押下したリストのアイテム情報をトースト表示する
listView.setOnItemClickListener { parent, view, position, id ->
Toast.makeText(this, array[position], Toast.LENGTH_SHORT).show()
}
こうすると、A problem occurred configuring root project 'My Application'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10-release-894.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.10-release-894/kotlin-gradle-plugin-1.5.10-release-894.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.10-release-894/kotlin-gradle-plugin-1.5.10-release-894.pom
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
どうやらkotlinのプラグイン「1.5.10-release-894」が見つからないらしい。。
AndroidStudio4.2がリリースされたのでアップデートしてみたら
新規プロジェクトをKotlinで作成すると、以下のエラーが出てビルドできなくなった。
A problem occurred configuring root project 'My Application'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
どうやらkotlinのプラグイン「1.5.0-release-764」が見つからないらしい。。
// java版
Set<String> set = new HashSet<>(
getSharedPreferences("set",MODE_PRIVATE).getStringSet("data", new HashSet<>()));
// Kotlin版
val set = getSharedPreferences("set", MODE_PRIVATE)
.getStringSet("data", mutableSetOf())?.toMutableSet()
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' // 追加プラグイン
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions' // 追加プラグイン
}
AndroidでTextViewなどのViewの表示切替を行った後、次回のアプリ起動でそのView表示可否状態を維持したいときの保存はSharedPreferencesが便利です。