我需要在應用程序中創建字段編輯頁面。有編輯聯繫人的EditText列表。對於每個字段類型我有一個佈局。例如 - 對於名稱和姓氏,它是浮動標籤的編輯文本。對於臉書 - 用圖標簡單編輯文字。我與Android的數據創建這個列表綁定庫Float標籤提示(TextInputLayout)不適用於Android數據綁定
我創建佈局
<data>
<variable
name="item"
type="app.core.db.model.Field" />
</data>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="65dp"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
app:theme="@style/EditFieldFloatLabeled">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:hint="@{item.getHint()}"
android:imeOptions="actionNext"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>
但浮動標籤不工作。我開始逐行評論找出原因。當我評論線時,浮標變成了工作
android:hint="@{item.getHint()}
(並用硬編碼文本替換它)。 getHint()
根據字段類型返回R.string.{something}
。
那裏我發現比編程設置提示產生浮標籤消失。我不能使用靜態佈局(而不是回收視圖),因爲字段列表可以動態地增加(例如:我正在寫字段中的電話號碼,空白的電話字段後面插入其他電話號碼)。
有沒有辦法以同樣的方式創建浮標(通過定義提示與字段類型)?
修復了我的問題。但爲什麼會發生? – mitsest