草庐IT

android - 对象不是 Kotlin 中此 Realm 的模式的一部分

我有一节这样的公开课openclassNewsResponse(@field:SerializedName("news")valnews:List?=null):RealmObject()像这样的NewsItem类openclassNewsItem(@field:SerializedName("created")valcreated:String?=null,@field:SerializedName("link")vallink:String?=null,@field:SerializedName("description")valdescription:String?=null,@

android - DatePickerDialog 已将 androidx.fragment.app.DialogFragment 中的按钮涂黑

这个简单的类:classDateSelectionDialogFragment:DialogFragment(){overridefunonCreateDialog(savedInstanceState:Bundle?):Dialog{valcalendar=Calendar.getInstance()valyear=calendar.get(Calendar.YEAR)valmonth=calendar.get(Calendar.MONTH)valdayOfMonth=calendar.get(Calendar.DAY_OF_MONTH)returnDatePickerDialog(

android - Kotlin - 在 Android 中转换 Singleton DatabaseController 的最佳方式

我正在通过“KotlininAction”学习Kotlin,并且正在慢慢将Android应用程序代码转换为它。但是我在转换下面的类时发现了一些问题。publicclassDatabaseController{privatestaticDatabaseControllersDatabaseController;privateSQLiteDatabasemDatabase;privateDatabaseController(Contextcontext){mDatabase=newSQLiteOpenHelperImpl(context.getApplicationContext()).g

android - 返回后的 kotlin android fragment 空回收器 View

我有这个安卓fragment:classMainFragment:BaseFragment(){privatevalrecyclerViewbylazy{find(R.id.recyclerView)}privatevalfabbylazy{find(R.id.fab)}privatevalmyLayoutManagerbylazy{LinearLayoutManager(ctx,LinearLayoutManager.VERTICAL,false)}privatevalmyAdapterbylazy{MainCardAdapter(ctx,ArrayList(),R.layout.c

android - Anko 主题和风格

有没有办法使用Anko将主题和样式添加到布局中?谢谢 最佳答案 我只是谷歌了同样的问题,并找到了答案here主题Anko也支持通过在任何View或布局之前的themed前缀来覆盖主题(xml方式是添加android:theme参数>到任何View):kotlinthemedLinearLayout(ThemeOverlay_AppCompat_Dark){orientation=VERTICALgravity=BOTTOM} 关于android-Anko主题和风格,我们在StackOve

android - Kotlin + 数据绑定(bind)在输入 '??' 处没有可行的替代方案

请原谅我糟糕的英语。我正在使用AndroidStudio3.1.1,我尝试使用kotlin对我的项目进行数据绑定(bind),但是当我尝试运行该项目时出现错误。我收到的错误消息如下所示:e:[kapt]Anexceptionoccurred:android.databinding.tool.util.LoggedErrorException:Founddatabindingerrors.****/databindingerror****msg:Syntaxerror:noviablealternativeatinput'??'file:/Users/eraise/Code/Demo/a

android - 注释参数必须是编译时常量

我看过this题。类似的错误。但在我的情况下是不同的。在使用Room时,我正在创建表格。它工作正常。@DaointerfaceUserDao{@Query("SELECT*FROMuser")fungetAll():List@Insert(onConflict=OnConflictStrategy.REPLACE)funinsert(user:User)@Deletefundelete(user:User)}但后来我发现所有表名都必须存储在不同的类中。像表名“user”->存储在不同的类中。例如。classTable{companionobject{constvalUSER_TABLE

android - 每当我尝试添加新的字符串资源时,Strings.xml 都会出现翻译错误

以下是我尝试添加新字符串资源时唯一的错误消息。注意:我没有进行任何本地化,只有默认值文件夹并仅使用androidstudio的提取字符串功能在strings.xml文件中添加字符串来self的xml布局。"string_name"istranslatedherebutnotfoundindefaultlocale. 最佳答案 在较新的AndroidStudio(v.3)中,任何以点命名的字符串都会导致“...在此处翻译但在默认语言环境中找不到”错误。如果你的strings.xml有这样的东西cccc你需要把它改成cccc

android - 排除由 Realm 插件添加的 Gradle 依赖项

偶尔,我的Gradle同步会失败。我会收到无用的消息,“第3方Gradle插件”可能是原因。如果我打开事件日志,我会看到消息:OutdatedKotlinRuntimeYourversionofKotlinruntimein'Gradle:org.jetbrains.kotlin:kotlin-stdlib:1.2.10@jar'libraryis1.2.10-release-109(1.2.10),whilepluginversionis1.2.51-release-Studio3.1-1.Runtimelibraryshouldbeupdatedtoavoidcompatibili

android - 使用 Kotlin 的 Android Realm - 在依赖项解析中包含配置后无法更改配置的依赖项

我正在尝试让Realm在我的项目中工作。我的Kotlin版本为1.2.51,并且禁用了InstantRun。在我的项目build.gradle文件中,我添加了以下依赖项:classpath"io.realm:realm-gradle-plugin:5.4.0"在我的Appbuild.gradle文件中,我按照教程中的说明应用了Realm插件:applyplugin:'com.android.application'applyplugin:'kotlin-android'applyplugin:'kotlin-android-extensions'applyplugin:'kotlin-