android editText setsingleline(false)输入框打不开了怎么搞的??

雨松MOMO 2010-12-27 10:35:47

//下面有两个输入框 我先点击输入框(editText)
editText = (EditText) findViewById(R.id.edit_text1);
editText.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
editNames.setSingleLine(true); //在这里把editNames的现实行数变成1行 。正常打开输入框。。
return false;
}
});

// 然后我在点击这个输入框
editNames = (EditText) findViewById(R.id.edit_text);
editNames.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
editNames.setSingleLine(false); //将自身的输入框行数变成自适应高度。可是这里问题就出来了,我怎么点击这个输入框,输入法都不会出来,如果没有 editNames.setSingleLine(false); 输入法就会出来 真的好奇怪 。 高手帮我解答一下吧在吗???
return false;
}

});
...全文
390 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ameyume 2010-12-27
  • 打赏
  • 举报
回复
        // 然后我在点击这个输入框
editNames.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
/*
* 将自身的输入框行数变成自适应高度。可是这里问题就出来了,
* 我怎么点击这个输入框,输入法都不会出来,如果没有
* editNames.setSingleLine(false); 输入法就会出来 真的好奇怪 。
* 高手帮我解答一下吧在吗???
*/
// editNames.setSingleLine(false);
editNames.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_CLASS_TEXT);
return false;
}

});

android:singleLine
Since: API Level Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. Note: for editable text views, it is better to control this using the textMultiLine flag in the inputType attribute. (If both singleLine and inputType are supplied, the inputType flags will override the value of singleLine.)
inputType比singleLine优先级高,还是用inputType吧
雨松MOMO 2010-12-27
  • 打赏
  • 举报
回复
真的好奇怪的问题。。

80,348

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧