展会信息港展会大全

如何通过回车提交EditView的内容
来源:互联网   发布日期:2016-01-14 11:32:17   浏览:1637次  

导读:private void initView() { postEditText = (EditText) findViewById(R.id.send_message); postEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent...

private void initView() {

postEditText = (EditText) findViewById(R.id.send_message);

postEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

@Override

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

if (actionId == EditorInfo.IME_ACTION_SEND) {

if (v.getText() == null || v.getText().toString() == null || v.getText().toString().length() == 0) {

UIHelper.ToastMessage("不能发送空的信息");

return false;

}

String postContent = v.getText().toString();

new CreatePostTask(postContent).execute();

return false;

}

return true;

}

});

}

<EditText

android:id="@+id/send_message"

android:imeOptions="actionSend"<!-- 回车进行发送 -->

android:inputType="text"

android:background="@null"

android:singleLine="true"

android:textColorHint="#d4d4d4"

android:hint="说点什么···"

android:layout_marginLeft="16dp"

android:layout_width="match_parent"

android:layout_height="match_parent" />

赞助本站

人工智能实验室

相关热词: android开发 android教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港