1)下面的代码:当我输入autocompletetextview时getView不会被调用。当心片段中的列表和适配器类扩展列表android arrayAdapter with autocomletetextview does not with List <...>
public class SigninFragment extends Fragment {
private List<Test> list= null;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Test tes= new Test();
tes.setId(1);
tes.setDesc("descabc");
list= new ArrayList<>();
list.add(prof);
tesListAdapter =
new TesListAdapter(
rootView.getContext()
,R.layout.list_row_adapter
,list);
autocompletetextview.setThreshold(3);
autocompletetextview.setAdapter(tesListAdapter);
我的适配器类别:
public class ProfissoesListAdapter extends ArrayAdapter<Test> { **<==HERE**
private LayoutInflater inflater;
private int resource;
public TesListAdapter(Context activity, int resource, List<Test> listaProf) **<==HERE**{
super(activity, resource, listaProf);
this.inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.resource = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
...
2)下面的代码:YES ...当我输入autocompletetextview时getView()会被调用。注意在片段中的String []数组和适配器exteding ArrayAdapter
public class SigninFragment extends Fragment {
private List<Test> list= null;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String[] list = {"abcde","bbbbbb","bbbakaka","ccccccc","dddddd"};
tesListAdapter =
new TesListAdapter(
rootView.getContext()
,R.layout.list_row_adapter
,list);
autocompletetextview.setThreshold(3);
autocompletetextview.setAdapter(tesListAdapter);
我的适配器类别:
public class ProfissoesListAdapter extends ArrayAdapter<String> { **<==HERE**
private LayoutInflater inflater;
private int resource;
public TesListAdapter(Context activity, int resource, String[] listaProf) { **<==HERE**
super(activity, resource, listaProf);
this.inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.resource = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
...
问题:为什么1)选项当我在自动完成textview中键入匹配值时,不会在适配器类中调用我的getView? thx
多数民众赞成它。我前几天已经修好了,你是对的。请在此评论框外回复,以便我可以查看您的答案。 thx – Al2x
这不是对其他问题的评论的原因? – Luksprog
nop。在另一个问题中,我有一个片段类和一个自定义适配器。当我调试适配器时,它无法找到RelativeLayout中的嵌套元素 – Al2x