I have an AutoCompleteTextView inside a RelativeLayout inside a FrameLayout. I want to populate the completion list using a class declared as follows:
public class AutoCompleteAdapter extends ArrayAdapter<String> implements Filterable {
...
public AutoCompleteAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
data = new ArrayList<String>();
}
...
}
I attached the adapter as follows:
AutoCompleteTextView tv = (AutoCompleteTextView) v.findViewById(R.id.editTextClient);
AutoCompleteAdapter adapter = new AutoCompleteAdapter(getActivity(), R.layout.fragment_main_right);
tv.setAdapter(adapter);
where R.layout.fragment_main_right is the enclosing FrameLayout mentioned above. When I start to input text, I get a ClassCastException with the following message: "android.widget.FrameLayout cannot be cast to android.widget.TextView". I understand this to mean that the second parameter in the ArrayAdapter constructor should be the id of something derived from a TextView. All the examples show this parameter as being the enclosing layout. Can someone clear up my confusion?