I have an activity consisting of 3 EditText fields (amongst other things like TextViews and a few buttons). I also have an AutoCompleteTextView with a list of String's using an ArrayAdapter.
Whenever I test the app in an emulator, I can type when the keyboard is up but it doesn't show the text (it still gives predictions) and the text only appears in the EditText box once the keyboard is closed down. This happens when I test it on my phone, too. However, it works and shows up as you type on the emulator if the on-screen keyboard isn't up and you're just typing normally.
I have no idea why!
Here is my Activity XML (where the EditText's are the top 3 blocks)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/l"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="3dp"
android:layout_y="5dp"
android:background="@drawable/gymbg" >
<AutoCompleteTextView android:id="@+id/inputExercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:inputType="text"
android:layout_alignParentRight="true"
android:layout_below="@+id/timeSet"
android:layout_margin="10dp"
android:layout_marginTop="50dp"
android:width="200dp" />
<EditText
android:id="@+id/inputWeight"
android:inputType="number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/inputExercise"
android:layout_margin="10dp"
android:layout_marginTop="50dp"
android:width="200dp" >
</EditText>
<EditText
android:id="@+id/inputReps"
android:inputType="number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/inputWeight"
android:layout_margin="10dp"
android:layout_marginTop="50dp"
android:width="200dp" >
</EditText>
<TextView
android:id="@+id/timeMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/timeMain"
android:textSize="32sp"
android:textColor="#0F293B"/>
<TextView
android:id="@+id/timeSet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/timeMain"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:text="@string/timeSet"
android:layout_marginBottom="50dp"
android:textColor="#0F293B"/>
<TextView
android:id="@+id/labExercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/addbutton"
android:layout_alignParentLeft="true"
android:layout_below="@+id/timeSet"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:layout_marginLeft="15dp"
android:text="@string/labExercise"
android:layout_toLeftOf="@+id/inputExercise"
android:textColor="#ffffff"/>
<Button
android:id="@+id/addbutton"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:text="@string/add" />
<Button
android:id="@+id/startStop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/addbutton"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:text="@string/startStop" />
<TextView
android:id="@+id/labWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/inputExercise"
android:layout_margin="10dp"
android:text="@string/labWeight"
android:textColor="#ffffff"/>
<TextView
android:id="@+id/labReps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/inputReps"
android:layout_margin="10dp"
android:text="@string/labReps"
android:textColor="#ffffff"/>
<TextView
android:id="@+id/seePrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/inputExercise"
android:layout_centerHorizontal="true"
android:layout_marginBottom="22dp"
android:text="@string/tapToViewPrevious"
android:textColor="#505050"/>
</RelativeLayout>
and here is the code I used in my activity: (I have stripped out unneccesary code)
public class MyWorkoutDiary1Activity extends Activity implements OnClickListener, TextWatcher
{
TextView seePrevious;
DatabaseHandler db;
AutoCompleteTextView myAutoComplete;
ArrayList<String> exerciseType = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
exercise = new EditText(this);
exercise = (EditText)findViewById(R.id.inputExercise);
db = new DatabaseHandler(this);
exerciseType = db.getUniqueExercises();
myAutoComplete = (AutoCompleteTextView)findViewById(R.id.inputExercise);
myAutoComplete.addTextChangedListener(this);
myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, exerciseType));
weight = new EditText(this);
weight = (EditText)findViewById(R.id.inputWeight);
reps = new EditText(this);
reps = (EditText)findViewById(R.id.inputReps);
}
}
Thanks for reading