我有两个文件one.kt and two.kt
,我在one.kt文件中有innerclass。我想在执行某些操作(如在Two.kt
文件中单击按钮)时调用该内部类。我尝试了一些方法,但是innerclass
或方法未调用。请指导我有什么错误。来自manifest
文件的One.kt文件调用。
像这样
<application
android:name="com.abc.cde.One"
One.kt
open class One : MultiDexApplication(), KodeinAware {
---------------
--------------
OnCreate()
---------------
---------------
inner class CallmyClass() {
fun CallMyMethod(i: Int) :Module {
return Module {
bind<ExchangeRateProvider>() with singleton { CryptoCompareExchangeProvider(this@One, instance()) }
bind<SyncProgressProvider>() with singleton { SyncProgressProvider() }
bind<WallethKeyStore>() with singleton { keyStore }
bind<Settings>() with singleton { KotprefSettings }
bind<CurrentTokenProvider>() with singleton { CurrentTokenProvider(instance()) }
bind<AppDatabase>() with singleton { Room.databaseBuilder(applicationContext, AppDatabase::class.java, "maindb").build() }
bind<NetworkDefinitionProvider>() with singleton { NetworkDefinitionProvider(instance()) }
//bind<CurrentAddressProvider>() with singleton { InitializingCurrentAddressProvider(keyStore, instance(), instance(), applicationContext) }
bind<CurrentAddressProvider>() with singleton { InitializingCurrentAddressProvider(keyStore, instance(), instance(), applicationContext,i) }
bind<FourByteDirectory>() with singleton { FourByteDirectoryImpl(instance(), applicationContext) }
}
}
}
}
Two.kt
class Two : AppCompatActivity(), KodeinAware {
-----------
-----------
-----------
oncreate()
-------------
--------------
val dd = One().CallmyClass().CallMyMethod(1)
}
注意:重要说明One.kt是从“应用程序”标签中的清单文件中调用的。
更新
如何通过Two.kt调用CallMyMethod(i:Int):Module {......}。现在调用了内部类,但未调用方法