簡體   English   中英

我如何制作動態線性布局以在 android 中顯示文本視圖?

[英]how can i make dynamic linearlayout to show textview in android?

我想創建一個動態文本視圖。 當用戶在編輯視圖中按確定輸入任何數據時,該數據將水平顯示在文本視圖中。 該數據將在 LinearLayout 或 RelativeLayout 中自動設置,如果該數據未放置在該行中,則自動設置在下一行中。

使用下面的代碼:

editText.setOnEditorActionListener { _, actionId, _ ->
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            str += ", " + editText.text
            textView.text = str
            return@setOnEditorActionListener true
        }
        return@setOnEditorActionListener false
    }

並在布局中為edittet設置以下屬性:

 android:imeOptions="actionDone"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM