I created a simple preference class that shows an AutoCompleteTextView control and it displays correctly, but when I focus on AutoCompleteTextView and start typing it, it calls up the keyboard, but then immediately loses focus on the control.
Any idea why this is losing focus?
Here is what I did to create the view. bloated layout is just a basic linear layout with title text in it.
I could change it to a preference for dialogue, but I think, but it would be smoother if it could be part of the basic representation.
@Override
protected View onCreateView(ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.base_preference, null);
if (mHint != null) {
TextView hintView = (TextView) layout.findViewById(R.id.PreferenceHintTextView);
hintView.setText(mHint);
}
TextView titleView = (TextView) layout.findViewById(R.id.PreferenceTitleTextView);
titleView.setText(getTitle());
AutoCompleteTextView inputView = new AutoCompleteTextView(getContext());
inputView.setGravity(Gravity.FILL_HORIZONTAL);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
R.layout.auto_complete_text_list_item,
getEntries());
inputView.setAdapter(adapter);
inputView.setThreshold(1);
inputView.setOnItemSelectedListener(this);
layout.addView(inputView);
return layout;
}
List item:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp"
android:textColor="#000">
</TextView>
may have been a standard list item and looked identical.
Brian source
share