简体   繁体   English

我如何制作动态线性布局以在 android 中显示文本视图?

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

I want to create a dynamic text view.我想创建一个动态文本视图。 When a user enters any data in the edit view pressed ok, that data will show on text view in horizontal.当用户在编辑视图中按确定输入任何数据时,该数据将水平显示在文本视图中。 That data will auto set in LinearLayout or RelativeLayout and if that data is not placed on that line automatic set in the next line.该数据将在 LinearLayout 或 RelativeLayout 中自动设置,如果该数据未放置在该行中,则自动设置在下一行中。

use the code below:使用下面的代码:

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

and set below attribute for edittet in the layout:并在布局中为edittet设置以下属性:

 android:imeOptions="actionDone"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM