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" />