我需要一些有关Android布局的帮助.我有以下代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.725" />
<TextView
android:id="@+id/data_field_1_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="10dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toTopOf="parent"
tools:text="ACTIVE" />
<TextView
android:id="@+id/data_field_1_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_toEndOf="@id/data_field_1_name"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_1_name"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="parent"
tools:text="1750" />
<TextView
android:id="@+id/data_field_2_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="8dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toBottomOf="@id/data_field_1_name"
tools:text="ACTIVE" />
<TextView
android:id="@+id/data_field_2_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dip"
android:layout_toEndOf="@id/data_field_2_name"
app:layout_constraintBaseline_toBaselineOf="@id/data_field_2_name"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="parent"
tools:text="1750" />
<TextView
android:id="@+id/data_field_3_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dip"
android:layout_marginTop="8dip"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toLeftOf="@id/guideline2"
app:layout_constraintTop_toBottomOf="@id/data_field_2_name"
tools:text="ACTIVE" />
<TextView …Run Code Online (Sandbox Code Playgroud) 我有一个关于 kotlin 流合并的问题。看看下面的乐趣。
suspend fun method(filter: String): Flow<List<Model>> {
// Search.
val models: List<Model> = repo.getModels(filter) // suspend function
// Get favorites
val favoritesFlow: Flow<List<Int>> = otherRepo.getFavorites()
// Return models as Flow, but mark/unmark every model as favorite when favoritesFlow is updated.
??? val result = models + favoritesFlow ????
return result
}
Run Code Online (Sandbox Code Playgroud)
我需要返回模型列表流,但是当最喜欢的流更改时,我必须将每个模型标记或取消标记为最喜欢的。你知道我该怎么做吗?