diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d19981..fbb6828 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/app/src/main/java/com/alfredayibonte/questionnaireview/MainActivity.java b/app/src/main/java/com/alfredayibonte/questionnaireview/MainActivity.java
index 690103f..43aca3f 100644
--- a/app/src/main/java/com/alfredayibonte/questionnaireview/MainActivity.java
+++ b/app/src/main/java/com/alfredayibonte/questionnaireview/MainActivity.java
@@ -1,8 +1,14 @@
package com.alfredayibonte.questionnaireview;
+import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
+import android.view.KeyEvent;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.TextView;
+
import com.alfredayibonte.questionnaireviewlib.QuestionnaireView;
import com.alfredayibonte.questionnaireviewlib.adapters.CheckListAdapter;
import com.alfredayibonte.questionnaireviewlib.adapters.RadioListAdapter;
@@ -12,7 +18,7 @@
public class MainActivity extends AppCompatActivity implements
CheckListAdapter.OnCheckItemClickListener,
- RadioListAdapter.OnRadioItemClickListener {
+ RadioListAdapter.OnRadioItemClickListener, TextView.OnEditorActionListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -20,9 +26,10 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
QuestionnaireView questionnaireView = (QuestionnaireView)findViewById(R.id.questionnaire);
questionnaireView.setQuestion("What is the name of moses' father ?");
- questionnaireView.setViewType(AnswerType.RADIO);
+ questionnaireView.setViewType(AnswerType.EDITTEXT);
questionnaireView.addRadioItemListener(this);
questionnaireView.addCheckItemListener(this);
+ questionnaireView.addOnEditorActionListener(this);
}
@Override
@@ -34,4 +41,10 @@ public void onCheckItemClick(List answers) {
public void onRadioItemClick(List answers) {
Log.e("radio answers: ", answers.toString());
}
+
+ @Override
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+
+ return (i == EditorInfo.IME_ACTION_DONE);
+ }
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 715610a..7d87655 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -10,8 +10,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:question="What is your name"
- app:view_type="radio"
- app:entries="@array/answers"
+ app:view_type="text_input"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
diff --git a/questionnaireviewlib/src/main/java/com/alfredayibonte/questionnaireviewlib/QuestionnaireView.java b/questionnaireviewlib/src/main/java/com/alfredayibonte/questionnaireviewlib/QuestionnaireView.java
index 00669ef..96690ad 100644
--- a/questionnaireviewlib/src/main/java/com/alfredayibonte/questionnaireviewlib/QuestionnaireView.java
+++ b/questionnaireviewlib/src/main/java/com/alfredayibonte/questionnaireviewlib/QuestionnaireView.java
@@ -5,6 +5,7 @@
import android.graphics.Color;
import android.text.InputType;
import android.util.AttributeSet;
+import android.view.inputmethod.EditorInfo;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.ListView;
@@ -77,7 +78,7 @@ private void drawInnerViews(Context context, AttributeSet attrs){
addView(listView );
//creation & addition of editText
- editTv = new EditText(context, attrs);
+ editTv = new EditText(context);
editTv.setVisibility(GONE);
editTv.setId(android.R.id.text1);
editTv.setLayoutParams(
@@ -89,7 +90,8 @@ private void drawInnerViews(Context context, AttributeSet attrs){
.create()
);
editTv.setInputType(InputType.TYPE_CLASS_TEXT);
-// editTv.setImeOptions(IME);
+ editTv.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ addView(editTv );
}
@@ -135,10 +137,6 @@ public void setViewType(int viewType){
}
- public void addOnEditorActionListener(EditText.OnEditorActionListener editorActionListener){
- editTv.setOnEditorActionListener(editorActionListener);
- }
-
public List getAnswers(){
return this.question.getAnswers();
@@ -186,6 +184,15 @@ public void addRadioItemListener(RadioListAdapter.OnRadioItemClickListener radio
radioAdapter.addListener(radioListener);
}
+ public void addOnEditorActionListener(EditText.OnEditorActionListener editorActionListener){
+ editTv.setOnEditorActionListener(editorActionListener);
+ }
+
+ public String getResponseFromEditText(){
+ return editTv.getText().toString();
+ }
+
+
private void makeListViewVisible(){
listView.setVisibility(VISIBLE);