我在我的应用程序中使用 MaterialComponents.DayNight 主题。在白天模式下,工具栏文本颜色为黑色。但是当我切换到夜间模式工具栏文本颜色保持黑色,所以它不再可见。
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)
我想在夜间模式下将工具栏文本颜色更改为白色。我怎样才能做到这一点?
android android-styles android-toolbar material-components material-components-android
我正在尝试使用对象库。
我阅读了官方文档并按照说明进行操作。但是仍然无法正常工作。
问题是当我尝试初始化boxStore对象时,找不到MyObjectBox类。
val boxStore = MyObjectBox.builder().androidContext(this).build()
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序模块。build.gradle(应用程序模块)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.objectbox'
android {
compileSdkVersion 26
defaultConfig {
....
}
buildTypes {
release {
....
}
}
sourceSets {
main.java.srcDirs += 'src/main/java'
}
}
kapt {
generateStubs = true
arguments {
arg("objectbox.debug", true)
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
... other dependencies
//object box
implementation "io.objectbox:objectbox-android:$objectboxVersion"
// some useful Kotlin extension functions
implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
kapt …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Flutter 中的互联网获取数据。但是我在 JSON 解析时遇到错误。谁能告诉我是什么问题?
我正在尝试从此 URL 获取数据
https://swapi.co/api/starships/
Run Code Online (Sandbox Code Playgroud)
示例 JSON
{
“计数”:37,
"next": "https://swapi.co/api/starships/?page=2",
“上一个”:空,
“结果”: [
{
"name": "执行者",
"model": "执行级星无畏",
"manufacturer": "Kuat Drive Yards, Fondor Shipyards",
"cost_in_credits": "1143350000",
"长度": "19000",
"max_atmophering_speed": "不适用",
“船员”:“279144”,
"乘客": "38000",
"cargo_capacity": "250000000",
"消耗品": "6 年",
"hyperdrive_rating": "2.0",
"MGLT": "40",
"starship_class": "星无畏",
“飞行员”:[],
“电影”:[
"https://swapi.co/api/films/2/",
“https://swapi.co/api/films/3/”
],
“创建”:“2014-12-15T12:31:42.547000Z”,
“编辑”:“2017-04-19T10:56:06.685592Z”,
"url": "https://swapi.co/api/starships/15/"
},
]
}
模型类
class RestModel {
final String name;
final String model;
final String manufacturer;
final String cost_in_credits;
final String length; …Run Code Online (Sandbox Code Playgroud) 我遇到两个错误
错误:带@Relation注释的字段不能为构造函数参数。在构造对象之后获取这些值。
错误:带@Relation注释的字段不能为构造函数参数。在构造对象之后获取这些值。
我有两个桌子。一个是任务表,另一个是子任务表。对于任务表的每个实体,子任务表都有一些实体。
所以我试图从单个任务中获取所有任务和子任务列表
道:
@Query("Select * from TaskTable")
fun getTasks():List<TaskModel>
Run Code Online (Sandbox Code Playgroud)
任务模型:
class TaskModel(
@Embedded
var taskTable: TaskTable,
@Relation(parentColumn = "id",
entityColumn = "taskId")
var subTaskTable: List<SubTaskTable>
)
Run Code Online (Sandbox Code Playgroud)
任务表:
@Entity
data class TaskTable(
@PrimaryKey(autoGenerate = true)
var id:Int = 0,
var taskListId:Int = 0,
var title: String,
var details:String?
)
Run Code Online (Sandbox Code Playgroud)
子任务表:
@Entity
data class SubTaskTable (
@PrimaryKey(autoGenerate = true) var id: Int = 0,
var taskId: Int = 0,
var title: String,
var details: String?) …Run Code Online (Sandbox Code Playgroud) android ×3
kotlin ×2
android-room ×1
dart ×1
flutter ×1
material-components-android ×1
objectbox ×1