我有这个阻止错误,阻止我启动我的应用程序。显然,此方法的签名需要泛型类型。我不明白我应该使用哪些类型......也许是Android Studio中的版本错误?到目前为止,互联网还没有帮助我......
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main) as ActivityMainBinding
supportActionBar?.hide()
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this)
activityMainBinding.rlMainLayout.visibility = View.GONE
getCurrentLocation()
activityMainBinding.etGetCityName.setOnEditorActionListener( { v, actionId, KeyEvent ->
if(actionId==EditorInfo.IME_ACTION_SEARCH){
getCityWeather(activityMainBinding.etGetCityName.text.toString())
val view = this.currentFocus
if(view!=null){
val imm:InputMethodManager=getSystemService(INPUT_METHOD_SERVICE)as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken,0)
activityMainBinding.etGetCityName.clearFocus()
}
true
}else false
} )
}
Gradle文件:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'master.kotlin.weather'
compileSdk 33
defaultConfig {
applicationId "master.kotlin.weather"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
dataBinding = true
viewBinding = true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
}
如果有人有办法的话
1条答案
按热度按时间dwbf0jvd1#
设置内容视图需要使用此代码。
如果你需要其他帮助,请随时询问。