EditTextView Android中的多行字符串(Multiline String in EditTextView Android)
我用这段代码创建了我的EditTextView:
mEditTxtZusatzInfo = new EditTextBackEvent(this);
mEditTxtZusatzInfo.setGravity(Gravity.START);
mEditTxtZusatzInfo.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mEditTxtZusatzInfo.setTextColor(Color.BLACK);
mEditTxtZusatzInfo.setBackgroundResource(R.drawable.edittextbackground);
后来我尝试将EditTextView的文本设置为:
test sdgdf
gdf
ghu
fjh#
sfk
dfopgjpdfjgpodfjgpodfjgdfg
dfgdfg42534
但文本只出现在一行中。
我查看了我的文字细节:
在HEX中,换行符保存为:“0A”
Notepad ++显示字符串正确!
如何让我的EditTextView显示多行?
谢谢你的帮助,抱歉我的英语不好。
最好的问候Schwandi
编辑:
EditText是一个扩展EditText的自定义类。
i have created my EditTextView with this code:
mEditTxtZusatzInfo = new EditTextBackEvent(this);
mEditTxtZusatzInfo.setGravity(Gravity.START);
mEditTxtZusatzInfo.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mEditTxtZusatzInfo.setTextColor(Color.BLACK);
mEditTxtZusatzInfo.setBackgroundResource(R.drawable.edittextbackground);
Later i try to set the text of the EditTextView to:
test sdgdf
gdf
ghu
fjh#
sfk
dfopgjpdfjgpodfjgpodfjgdfg
dfgdfg42534
But the Text only appears in one single line.
I looked at my text detail:
in HEX linebreaks are saved as: "0A"
Notepad++ displays the String correct!
How can i make my EditTextView to display the mulitple lines?
Thank you for your help and sorry for my bad english.
Best regards Schwandi
EDIT:
EditText is a custom class which extends EditText.
原文:https://stackoverflow.com/questions/13605597
更新时间:2019-11-28 16:32
最满意答案
使用此setSingleLine()将单行属性设置为false;
mEditTxtZusatzInfo.setSingleLine(false);
并且您还必须将高度设置为wrap_content,否则它不会增加其视图高度
set the single line property as false using this setSingleLine();
mEditTxtZusatzInfo.setSingleLine(false);
and also you must set the height as wrap_content otherwise it will not increase its height of view
2012-11-28
相关问答
我不确定showProfileActivity的作用,但是因为你传递了userId我假设它做了另一个查询? 为什么不这样做: 假设用户名是唯一的(在这种情况下,你似乎也在假设)然后findInBackground方法应该只返回一个用户。 query.findInBackground(new FindCallback() {
public void done(List objects, ParseException e) {
...
为什么你不认为在Android框架中创建一个包含视图的布局是在图形界面中公开某些数据的好方法? 这是View类甚至存在的唯一原因。 它是应用程序GUI的主要构建材料。 你也不需要手工创建它。 您只需要能够在构建您的Activity实例的Java代码中处理您的ViewGroup (布局)对象。 从那里你有一个addView()方法,你可以在一个简单的循环中添加视图(注意,这样你可以创建每个尺寸的网格,而不仅仅是6x6)。 请熟悉官方Android Developers网站,您可以在其中阅读与Andr
...
从Android开发人员的这个线程 ,它接缝ViewParent和ViewGroup一般不能删除视图。 您需要将您的父级转换为布局(如果是布局)才能完成所需。 例如: //syntax error in View
View namebar = View.findViewById(R.id.namebar);
((ViewGroup) namebar.getParent()).removeView(namebar);
From this thread on android-developers,
...
使用此setSingleLine()将单行属性设置为false; mEditTxtZusatzInfo.setSingleLine(false);
并且您还必须将高度设置为wrap_content,否则它不会增加其视图高度 set the single line property as false using this setSingleLine(); mEditTxtZusatzInfo.setSingleLine(false);
and also you must set the heig
...
经过大量的杂耍,我终于解决了这个问题,但我仍然无法弄清楚实际的问题。我做的是我写了一个单独的函数来获取多行文字。 它就像一个魅力 private EditText getMultiLineEditText(String sHint,int id,Drawable drwable,String tag,int fldType,int fldFlag)
{
EditText editTxt;
LinearLayout.LayoutParams params = new LinearLa
...
其中一个解决方案就是使用uiautomator 。 它拥有打开电子邮件应用程序并单击链接所需的一切。 One of the solution is to use uiautomator for this. It has everything you need to open email app and click the link.
它工作得很好..它只是说你的测试用例失败,因为EditText中的文本不等于你的比较文本。试试这个/ .. @Override
protected void setUp() throws Exception {
super.setUp();
mActivity = this.getActivity();
username = (EditText) mAct
...
你得到一个NullPointerException,因为你永远不会初始化keyArrayList 。 NPE发生在这一行: keyArrayList.add(tempString); 只需在onCreate()初始化它。 public class MainActivity extends ActionBarActivity {
private String numString = "";
private ArrayList keyArrayList;
Edi
...
解决方案是通过邮件发送单独的UI消息。 这肯定会起作用。 在ScrollView里面的TextText / Append文本添加到TextView后,通过post(Runnable)方法更新ScrollView,如下面的代码所示: messageView.append(blabla);
scroller.post(new Runnable() {
public void run() {
scroller.smo
...
为什么不将它们放入并将一个放在EditText的左侧和右侧。 像这样的东西:
android:layout_toLeftOf="@+id/edit_text"/>
android:layout_toRightOf="@id/edit_tex
...