1
0
mirror of https://github.com/pierre42100/ComunicAndroid synced 2025-05-16 08:31:08 +00:00

User can hit enter to send a comment

This commit is contained in:
Pierre 2018-05-07 17:32:56 +02:00
parent 120872a131
commit a7e812b8e5
2 changed files with 17 additions and 1 deletions
app/src/main
java/org/communiquons/android/comunic/client/ui/adapters
res/layout

@ -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<Post>{
}
});
//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;
}
});
}
}

@ -115,7 +115,7 @@
android:layout_weight="1"
style="@style/TextAppearance.AppCompat"
android:hint="@string/new_comment_hint"
android:inputType="textMultiLine" />
android:inputType="text" />
<ImageView
android:id="@+id/comment_send_button"