我尝试使用自定义适配器实现AutoCompleteTextView,但它没有向我显示建议列表。
这是我的活动片段:
Member newMember = new Member();
newMember.setMemberID(1);
newMember.setMemberName("TEST 1");
mAllMemberList.add(newMember);
newMember = new Member();
newMember.setMemberID(2);
newMember.setMemberName("TEST 2");
mAllMemberList.add(newMember);
mMemberInputField = (AutoCompleteTextView) findViewById(R.id.memberInputField);
mAllMemberListAdapter = new MemberInputListAdapter(this, mAllMemberList);
mMemberInputField.setAdapter(mAllMemberListAdapter);
MemberInputListAdapter.java
public class MemberInputListAdapter extends ArrayAdapter<Member> {
private Context mContext;
private ArrayList<Member> mMembers = new ArrayList<Member>();
public GroupMemberInputListAdapter(Context context, ArrayList<Member>members) {
super(context, R.layout.all_member_listview_item, members);
mContext = context;
mMembers = members;
}
@Override
public View getView(final int rowPosition, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.all_member_listview_item, parent, false);
return rowView;
}
}
Member.java
public class Member implements Serializable{
private int memberID;
private String memberName;
public int getMemberID() {
return memberID;
}
public void setMemberID(int memberID) {
this.memberID = memberID;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
@Override
public String toString() {
return memberName;
}
}
当我开始输入&#34; Tes&#34;?
时,我怀疑我的AutoCompleteTextView
没有显示任何内容