From a7e812b8e5e8101a9a94f518e73858fe63fd320c Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 7 May 2018 17:32:56 +0200 Subject: [PATCH] User can hit enter to send a comment --- .../comunic/client/ui/adapters/PostsAdapter.java | 16 ++++++++++++++++ app/src/main/res/layout/post_item.xml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java index c22edcf..8500a8a 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.ArrayMap; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -243,6 +244,21 @@ public class PostsAdapter extends ArrayAdapter{ } }); + //Make the comment input behaves like the send button when the user hit the + //enter key + input_comment.setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + + if(event.getAction() == KeyEvent.ACTION_DOWN + && keyCode == KeyEvent.KEYCODE_ENTER){ + sendComment(position, finalConvertView); + } + + return false; + } + }); + } } diff --git a/app/src/main/res/layout/post_item.xml b/app/src/main/res/layout/post_item.xml index 20920cb..c09d95a 100644 --- a/app/src/main/res/layout/post_item.xml +++ b/app/src/main/res/layout/post_item.xml @@ -115,7 +115,7 @@ android:layout_weight="1" style="@style/TextAppearance.AppCompat" android:hint="@string/new_comment_hint" - android:inputType="textMultiLine" /> + android:inputType="text" />