gpt4 book ai didi

android - 以编程方式创建多行 EditText

转载 作者:IT王子 更新时间:2023-10-28 23:26:48 26 4
gpt4 key购买 nike

我正在尝试通过代码创建多行 EditText。这是我使用的:

EditText txt = new EditText(this);    
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f);
txt.setLayoutParams(lp);
txt.setSingleLine(false);
txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);

但它仍然在一行中。

最佳答案

应该这样做

txt.setSingleLine(false);
txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);

关于android - 以编程方式创建多行 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15032870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com